Re: Survey, what tool do you use?
> What development tool do you use to help on daily coding? pico :) dstn.
Re: Survey, what tool do you use?
> Pico? Pah! Try vi. Grr! :) vi schmi :) dstn.
Re: Transparent gif files
Hi, One alternative is to write your own GIF class like I did. :) That's a great solution if you like bit-twiddling :) Some things that may or may not be useful: -The GIF file format specifies the background index (palette entry) in the header. -The Color of the transparent pixels should be 0,r,g,b. The zero says the Alpha value is zero: the pixel has no opaqueness. > My question concerns producing transparent gifs thar are transparent on all > platforms (linux, win95 and Macintosh). With Java, or an image-editing program? Paint Shop Pro 5 (and 4 too, I think) allow you to specify which palette entry is transparent. I've found that PSP 5's transparency doesn't always work properly, at least for GIF89a format. Feel free to e-mail me off this list, I might be able to help. Seeya, dstn.
Re: Unidentified subject!
Hi, > Is it possible with Java to rotate a font (90 degree)? > I want to write from top to bottom in a canvas. > Perhaps you have another solution. I don't have an easy sorution, but I can tell you how I'd do it: -create an offscreen Image -get its Graphics and draw the text left-to-right on it -use a java.awt.image.PixelGrabber on it -do some array twiddling to rotate the image -use a MemoryImageSource on the resulting twiddled array. Like I said, not easy, but it would actually not take very long (runtime, that is). Cheers, dstn.
Re: migration to linux
Hi, > I want to instal Redhat linux to run in dual boot mode with win95 and > need the capacity to use the JDK with both. > I want the power of UNIX at home but am > afraid of switching without getting some more detailed knowledge first. > Unfortunately I have no experience in compiling and configuring an OS so > I thought I'd try one of the more popular binaries available. > > Any help would be very much appreciated, either with a better flavor of > linux to use or with how to port the JDK to linux. I had very little experience with unix before I put linux on my machine. I got the slackware cd-rom set and had a trouble-free install and have been happily running a dual-boot system for some time. Sometimes if you have to re-install win95 it will mess with the OS-booter (I was using LILO)... silly microsoft products... As for the JDK, I use the Sun JDK on Win95 and Steve Byrne's port of the JDK on Linux. I also use Linux and SB's JDK on my work machine, and have never had a problem with either. I think the Linux compiler is faster than the Win95 one, too. I'm working on a fairly major Java project, so the JDK is getting a real workout, and it has performed flawlessly. And no, nobody is paying me to say this stuff :) By the way, Steve and everyone else involved, thanks very much for a great piece of software!!! dstn.
Re: Problems with the componentListener and JTextField.
Hi, I found the same thing with a non-Swing app: componentResized but no componentShown. > I have added the ComponentListener to the JTextField, but never reach > the componentShown() event. It makes componentResized() and > componentMoved() when it is shown, but no componentShown().
Re: sending image
Hi,
> I'm writing a Java server application which sends (via socket) an image
> to an applet.
Good luck. Image objects are not serializable. In other words, they are
not willing to be sent over a network. I encountered the same problem in
my work. The reason, or so Sun claims: Image objects are stored in a
OS-dependent manner. Here's a workaround:
import java.awt.image.*;
Image image = (your image);
int w = (width of the image);
int h = (height of the image);
int pixels = new int[w*h];
PixelGrabber pg = new PixelGrabber(image, 0, 0, w, h, pixels, 0, w);
try {
pg.grabPixels();
} catch (InterruptedException ie) {
}
Send that int array to the client. On the client side,
int[] pixels = (int array from the server);
int w = (image width);
int h = (image height);
Image image = createImage(new MemoryImageSource(w, h, pixels, 0, w));
> What is wrong?
> Does anyone know if there is a better way to send image via socket?
I don't know if I'd call that BETTER, but it works :)
dstn
Re: CMS Problem: Incorporate as a Nonprofit?
Hi, This may not be a concern at all, but you might want to consider a not-for-profit instead of nonprofit organization. Cheers, dstn. > Does a nonprofit > organization sound helpful for any other reasons? Would you feel > comfortable joining?
Re: Java 1.2 and Java3D for Linux...?
> Although a little unrelated it may be interesting to you: SUN is selling Solaris > 2.6 for both Sparc and x86 architectures at $ 10.00 + shipping. Now, does this make sense to anyone else: from sun's web site I can order solaris, for $10. My choices for shipping are: USPS Global Priority Mail, $27 Airborne Express, $33.50. Add the crappy Canadian dollar on that and Solaris is actually about $55 Canadian. Oh well, didn't want Solaris anyways! *grin* dstn.
Re: libXpm.so, where can i get it?
Hi, > I'm running on slackware with kernel 2.0.3* and I downloaded the JDK 116 from >blackdown. when I try to run the java > or the javac program, I get an error that says that libXpm.so is not found. I read >somewhere else > where libXpm.a used to solve the problem. > Where can I get a copy of this file or what package does it come in? It can be found in the slackware "x1" disk set, file "xpm.tgz". You can find it at your favourite slackware mirror site. dstn.
Hogging colours?
Hi, I was looking at some stuff I wrote a long time ago (before I had a sane operating system *grin*), that does something similar to 'xlock -mode swirl' (makes pretty wavy things). When I ran it in X, instead of hundreds of colour I got 4. It's not nearly so pretty in 4 colours. *pout* Does anyone know how to make java be more assertive in its demands to use many colours? My hardware is able to do 64k colours and at the moment I have X configured to use 256. Thanks, dstn.
Re: Java Awt/Swing is fatally flawed
Hi, Please excuse my few snarky remarks... :) > This bring up a basic problem with Linux. It's intel centric. Although > linux runs on a multitude of CPU's it is still centered around > the intel cpu. It's offered e quit a bit of freedom in choosing a free > OS. but try finding binaries for the alternative platforms. They're called .class files *grin* > Within the Linux community > few have left the intel dominated computer market. The only part of the linux community I can tell you about is the one I belong to: young hackers. I bought my ultra-budget computer with money from my McJob. It came with (a most-likely pirated copy of) Windows. I used Win until I discovered how awful it was. When I found out about Linux I installed it and finally escaped M$. When I buy my next computer, I will look into other hardware from other manufacturers. (I could use a SparcStation *grin*) > The application programmer face tow > porting issues binary comaptibility and API's. Java. Check and check. > Java server side programs are extremely portable assuming you don't > write them only on NT. Writing on NT can be a challenge in itself. One of my coworkers needed to use a Process in a server he was writing. On Linux it worked just fine. On NT the Process never completed (calling waitFor() never returned). > The current free software recompile crud is good for > geeks but cannot be taken mainstream. *grin* I think some of us like it that way. Linux has a sort of home-grown feel that I much prefer to any M$ product. (Biased opinion; I has the pleasure *groan* of trying to fix my parents' M$ box). Just my daily rant, dstn.
Profiler for Linux?
Hi, I've been playing with GIF images and am having major performance issues - it's just taking too long to read and write the files! I'm interested in getting some profile information on my code. I tried the "java_g -prof" option, and I guess that's enough information, but Metrowerks (makers of codewarrior), has a pretty good profiler... for Macintosh (ouch!). Can anyone point me to a good profiler for Linux? Thanks, dstn. ----- Dustin Lang, [EMAIL PROTECTED]
Profiling? (Part II)
Oh yes, another thing I forgot to mention: is anyone aware of a way of profiling a server or other program that doesn't normally exit? I have a server program doing some dynamic image creation, but I can't get a profile on it without rewriting the code (which I'm not eager to do!), since it never normally exits. Thanks, dstn. --------- Dustin Lang, [EMAIL PROTECTED]
Re: Installing JDK on Linux Slackware
Hi, > I´m having a lot of problems installing JDK1.1.7 on Linux Slackware. Is it > really possible? If not, anybody know a version of JDK for Slackware. I've set it up on two slackware systems with version 1.1.6. In both cases they worked perfectly right out of the box. I think this is more a result of luck than any particular sysadmin skill on my part. The first one is my work computer. It is kernel version 2.0.27 (yes, I know, ancient). It has libc5.4.44 and ld.so -> ld-linux.so.1.8.2. It also has a whole whack of other stuff. Those are the suggested library versions at java.blackdown.org. The second is my home computer. Kernel 2.0.34, and stock slackware 3.5 libs. It has about half a whack of other stuff. I've also used some other versions (1.1.5? Can't recall), never with problems. Make sure you have the libc5 version of the JDK and NOT the glibc. The java compiler is just a wrapper to the java program, so your problem is likely with java itself and not just the compiler. Good luck, dstn.
Re: java/Netscape question
Hi, > Is it possible to remove the Save, Send page, Send and View Page Source > options from a browser when viewing a page so that the page is totaly > secure ? Are you trying to prevent a web page from being copied? One of us doesn't understand your question. Warning: silliness below this line -- Try this: telnet 209.52.200.3 80 when the connection opens, type (verbatim) GET / being sure to put in two carriage returns. You can replace 209.52.200.3 with your favourite web server. After that exercise, it should be clear that there are very few solutions to making web things "secure". One is: cd /var/lib/httpd/htdocs chmod 600 file That'll protect it. *grin* dstn.
JDK 1.1.6 + Kernel 2.2 = Happy
Hi, Just in case anyone was wondering, I installed the release kernel 2.2.0 and java (Blackdown JDK1.1.6, green threads, libc5) works flawlessly. Thanks for the great work, dstn. - Dustin Lang, [EMAIL PROTECTED]
JDK1.1.7 + kernel 2.2.0 = Happy (?)
Hi gang, After upgrading my XFree86, I installed JDK117 and it seems to be running fine under kernel 2.2.0. At least, ICQ and my client/server pair started fine and seem to be happy. The biggest problem I've seen so far is that I forgot to move jikes into the new java/bin directory =) Teehee... I wrote a versioning client/server for my lab, and it uses a List object that was subject to a bug when removing element 0 (under JDK116). I didn't really realize how used to the bug I was. I almost miss it :) Oh yeah, and my buttons look different :) Cheers, dstn. ----- Dustin Lang, [EMAIL PROTECTED]
Frames not showing up quite correctly?
Hi,
Before I submit this to jitterbug, I'd like to make sure I'm not just on
crack.
This used to work before I upgraded (to JDK1.1.7, XFree86 3.3.3.1, and
kernel 2.2.0, from JDK1.1.6, XFree86 3.3.2(?), kernel 2.0.36. Window
manager = fvwm2). It also works correctly on win32. I don't have access
to a Solaris machine to check if it happens there.
What happens, at least for me, is the Frame shows up on screen at the
right size, but the body of it is all gray. If I drag it to a nearby
location, it is drawn correctly. Also, if I uncomment the last line, it
is drawn correctly.
I'm not sure, but I believe it should be drawn correctly without the
explicit setLocation?
Thanks (and sorry for wasting your time if I am in fact on crack),
dstn.
---
import java.awt.*;
import java.awt.event.*;
public class FrameTest extends Frame {
public static void main(String[] args) {
new FrameTest("Test", "This is a test");
}
public FrameTest(String title, String text) {
super(title);
add("Center", new Label(text, Label.CENTER));
Button okay = new Button("Okay");
add("South", okay);
setBackground(Color.white);
okay.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
((Frame)((Component)e.getSource()).getParent()).dispose();
System.exit(0);
}
});
pack();
setResizable(false);
show();
// This will make it be drawn correctly.
//setLocation(10,10);
}
}
-
Dustin Lang, [EMAIL PROTECTED]
which JDK?
Hi, I feel really stupid for having to ask this, but is there a way to find out what flavour of Linux one has? (RH, Slackware, etc.) I have no idea what is installed on my work machine. As soon as I find that out, my next question (probably a FAQ) is, what's the (newest && workingest) version? Thanks, dstn. ----- Dustin Lang, [EMAIL PROTECTED]
Removing items from Choices...
Hi,
I'm working on a multi-player game using RMI, and I've encountered an odd
problem that I don't believe is the result of silliness on my part.
I have a Choice object where players choose their character. If another
player picks a character, I'd like to remove that item from the Choice for
all the other players (can't have more than one player using the same
character!). I do this, basically:
Choice c = new Choice();
c.add("Choice one");
c.add("Choice two");
c.add("Choice three");
then later...
c.remove(0);
After an item has been removed, trying to choose a different item (esp.
the last item) causes:
java.lang.IllegalArgumentException: illegal Choice item position: 2
at java.awt.Choice.select(Choice.java:298)
at sun.awt.motif.MChoicePeer.action(MChoicePeer.java:86)
at java.lang.Thread.run(Thread.java)
I've just upgraded to jdk1.1.6v2 (I was running 1.1.3 and thought that
might have been fixed in 1.1.6). It would be easy enough to hack out a
solution, but this same code segment works on NT.
Thanks,
dstn.
-
Dustin Lang, [EMAIL PROTECTED]
Re: Great!
> The unscubscribe header is a great improvement! > It was time the "unsubscribe" message traffic get wiped out! Maybe we could add a "Asking when 1.2 will be done will result in unsubscription from this list and subscription to as many AOL spam lists as possible. Don't ask!!" *grin* dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Uh oh...
Hi, In fairly normal operation of my fairly large program, I got a "SIGSEGV 11 segmentation violation". Not the right-at-startup-because-you-have-the-wrong-library-version,-stupid type, just smack dab in the middle of my code. The same thing happened earlier today, but I didn't catch the output. Is there anything I can do with the thread dump to figure out what's causing it? Where the crash occurred I do a wait-notify, waiting for an RMI network call to dispose a modal dialog box. On a side note, am I correct in assuming that, in threory, there is nothing 100% java code can do to cause a virtual machine to crash? The thread dump is available at http://taz.cs.ubc.ca/java/segfault1.out I'm not sure if a code snippet will be useful, since that probably won't cause a crash. Oh yeah, this is jdk1.1.7a with kernel 2.2.1. Thanks very much, dstn. ------ Dustin Lang, [EMAIL PROTECTED] (java developer,linux guy, all-round goofball) -- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Linux jdk 1.,2 Jit
Hi, > Both TYA and the ShuJIT are free JIT's which work with Linux and JDK 1.1 ... > I am assuming that porting them to work with JDK 1.2 will not be (too) > difficult. I know nothing, but I've heard that the interface for JITs has changed a lot between 1.1 and 1.2. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: calling compiler withing a program?
> > Does anyone know how to call the java compiler from within a java
> > program and without using Runtime.exec()?
>
> It is not a question specific to Java and *Linux*.
> Here is not just proper place to ask it.
>
> You can make use of the class sun.tools.javac.Main as:
>
> sun.tools.javac.Main javac = new sun.tools.javac.Main(System.out, "javac");
> javac.compile(new String[]{"Foo.java"});
>
> Sun don't make the sun.* API open to the public.
But you can javap them :)
If you plan on distributing this, check to make sure the JRE classes.zip
actually contains the sun.tool.* hierarchy. I don't think it does.
dstn.
--
Dustin Lang, [EMAIL PROTECTED]
(java developer,linux guy, all-round goofball)
--
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: problem with Installation
Hi, > qcharles> hi, I got problems when using java interpreter, > qcharles> appletviewer, etc.. the system shows the error messages > qcharles> are : $ java -version > qcharles> /usr/local/jdk117_v1a/bin/../bin/i586/green_threads/java: > qcharles> error in loading shared libraries libjava.so: cannot > qcharles> open shared object file: No such file or directory Could it be a permissions problem? *shrug* dstn. --- -- Dustin Lang, [EMAIL PROTECTED] -- (java developer, linux guy, green-haired freak) --- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Way to go!
Hi, Sorry for adding to the noise, but there seems to be a lot of green on the JDK1.2 status page!! Way to go!! dstn. --- -- Dustin Lang, [EMAIL PROTECTED] -- (java developer, linux guy, green-haired freak) --- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Emacs and java...
Hi, I know this isn't really on-topic but I'm sure there is someone on this list with the answer... I've decided to give Emacs a try (I normally use pico :) for my java development (my full-time job). Can anyone tell me how to set the character emacs uses to indent? Right now it's using two spaces as a tab. I'm a believer in the a-tab-is-a-tab axiom of indentation :) Help?! Thanks, dstn. ----- Dustin Lang, [EMAIL PROTECTED]
AWT Bug? Threading problem? Or am I losing my mind?
Hi,
I'm building a versioning server-client pair using RMI and I thought it
would be fun to have a little traffic light to indicate that something is
happening: green means go ahead, red means it's busy doing something. I
wrote Light.java, an excruciatingly simple traffic light. At the start of
the actionPerformed method in the versioning client, I set it red (which
calls repaint internally), and at the end I set it green. There's only
one problem: it doesn't work.
I wrote a little demo (Test.java)
Here's what happens:
when setColor is called in some places (say, the Test constructor), it
works just fine (whee, it's a traffic light!). when setColor is called
within the actionPerformed method, the repaint doesn't go through until
the end of the actionPerformed method is reached. I tried doing
repaint(10L), with the same result.
Here's my explanation:
the event distributing thread is a higher-priority thread than the
repainting one, and this somehow messes up the repaint() call.
Let's make the assumption that I haven't made a glaring error (may not be
a reasonable assumption since my brain is a bit fried), and assume that
this is in fact a bug. Now, this is by no means a major bug, and I'm sure
I could do a work-around, but if repaint(10L) is called, shouldn't paint
get called within 10 ms, regardless of what other threads are executing?
Or am I on crack?
Thanks,
dstn.
import java.awt.*;
import java.awt.event.*;
public class Test extends Frame implements ActionListener {
Light light;
Button go;
public static void main(String[] args) {
new Test();
}
public Test() {
light = new Light(15);
light.setColor(Color.green);
go = new Button("Go!");
go.addActionListener(this);
setBackground(Color.white);
add("North", go);
add("South", light);
setTitle("Test!");
pack();
show();
}
public void actionPerformed(ActionEvent e) {
light.setColor(Color.red);
try {
Thread.sleep(2000L);
} catch (InterruptedException ie) {
}
light.setColor(Color.blue);
try {
Thread.sleep(2000L);
} catch (InterruptedException ie) {
}
light.setColor(Color.green);
}
}
import java.awt.*;
public class Light extends Canvas {
int dia;
public Light(int d) {
dia = d;
}
public Dimension getPreferredSize() {
return new Dimension(dia,dia);
}
public void setColor(Color c) {
setForeground(c);
System.out.println("Repaint!");
repaint(10L);
}
public void update(Graphics g) {
System.out.println("Update!");
paint(g);
}
public void paint(Graphics g) {
System.out.println("Painting (color is " + getForeground().toString()
+ ")");
g.setColor(getBackground());
g.fillRect(0,0,getSize().width,getSize().height);
g.setColor(getForeground());
g.fillOval(0,0,dia,dia);
}
}
AWT Bug?
Hi again, I ran Test on NT and it does the same thing. Weird... dstn. - Dustin Lang, [EMAIL PROTECTED]
More AWT Woes...
Hi again, I tried putting in a Toolkit.sync() in my traffic-light problem... in fact I loaded it down with many sync()s, but still with no luck. Is there something so wrong with traffic lights? Oh well, time to do some threading... Seeya, dstn. - Dustin Lang, [EMAIL PROTECTED]
Using sun.tools.javac.Main within a java app?
Hi, Let me pause for a moment and smack myself for sending this admittedly off-topic message. (Flame at will) *SMACK* Okay, now, has anyone ever used sun.tools.javac to do compiling within a running vm? I'm writing a versioning server that can compile java files and right now I'm using the most naiive way: running it as a Process. Blah. Thanks, dstn. PS - I did actually look on the web for quite a while but without much success. ----- Dustin Lang, [EMAIL PROTECTED]
Re: Using sun.tools.javac.Main within a java app?
Hi, Let me pause for a moment and smack myself for being such a goof. *SMACK* I think I was just incorrectly interpreting the results of my initial tests on the compile() method; it works exactly as one might expect: takes args such as "-d", "-O", and the list of files to compile. Sorry for the spam, dstn. > Let me pause for a moment and smack myself for sending this admittedly > off-topic message. (Flame at will) > > *SMACK*
More sun.tools.javac craziness...
Hi (yet again), I ran some tests on the whole Process vs. javac.Main.compile, and came up with results that are exactly the opposite of what I'd expect. My assumption: using a Process involves running the command "javac -d dir File.java", which involves starting up a JVM, which is a CPU- and memory-intensive operation. Calling javac.Main.compile within the currently-running VM doesn't involve starting up a new VM and should thus use fewer resources and thus finish faster. The test: compile all the files in a given directory. Use System.currentTimeMillis() to track how long they take. After assembling appropriate String arrays called cmd, these are the commands: new Main(System.out, "javac").compile(cmd); Runtime.getRuntime().exec(cmd).waitFor(); The results: Note: I tried with and without TYA, tried changing the order (ie, do Main(...) first or do Runtime(...) first, with no appreciable change (stddev swallows up the diffs) Process: avg 19800, stddev ~500 Main:avg 23800, stddev ~500 (this is the result of 6 tests) Hmmm Thanks, dstn. ----- Dustin Lang, [EMAIL PROTECTED]
compiler crashes
Hi, I'll keep this brief since I submitted a bug (at blackdown, #112 incoming) with details. When compiling a big project (~150 source files), javac keeps crashing with: sun.tools.java.CompilerError: stackSize null at sun.tools.java.Type.stackSize(Type.java) at I've tried cranking up the stack size with java -ms32M sun.tools.javac.Main with the same result. Has anyone seen this (and hopefully found a way to fix it)? Thanks, dstn. ----- Dustin Lang, [EMAIL PROTECTED]
Re: multi JVM's mem usage in linux?
Hi, This is horribly off-topic so please flame me to death. > Or you could run a single JVM with each "application" running in its own > thread. They should not interfere with each other (much!), provided your > applications don't expect to be able to call System.exit() and other global > methods. I was working on an application to run multiple Java apps in one VM in such a way that it was transparent to the apps, and that would allow the user to kill one app, get info about an app, and so on. I gave up after a while because I had actual work to do. You can create your own custom security manager that disallows System.exit() calls. By doing custom security you can do other neat stuff too, like keep track of which thread created a given window, and so on. dstn. ------- -- Dustin Lang, [EMAIL PROTECTED] -- (java developer, linux guy, green-haired freak) Why Linux is so cool: /usr/include/string.h:190: /* Sautee STRING briskly. */ extern char *strfry __P ((char *__string)); --- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: multi JVM's mem usage in linux?
Hi,
> Yes, but how do one actually *stop* the application manually, after having
> denied the System.exit() call? I was playing with the idea to write an echidna
> type app (as a learning experience), but never got started because I couldn't
> solve that simple problem :)
Only allow a given thread to stop the application. A hackish example
would be this:
System.setSecurityManager(new SecurityManager(){
public void checkExit(int status) {
if (!Thread.currentThread().getName().equals("kill
thread")) throw new SecurityException("naughty naughty.");
}
}
You could also use a special magic status number, such as 0xCAFEBABE :)
dstn.
-------
-- Dustin Lang, [EMAIL PROTECTED] --
(java developer, linux guy, green-haired freak)
Why Linux is so cool: /usr/include/string.h:190:
/* Sautee STRING briskly. */
extern char *strfry __P ((char *__string));
---
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: This works on Linux/ W95 not on NT. Why?
Hi, > > Maybe because NT is notorious for being very unfriendly to Java? I've noticed that some processes initiated with Runtime.exec() on NT never terminate, ie, process.waitFor() never returns. Of course, it worked flawlessly on Linux. (Thanks porting team! You rock!) > Huh? NT is one of the best Java platforms around. Hahahaha that's a good one. One of the apps I'm working on crashes with Dr.Watsons within 20 minutes. > It's relatively stable Hehehehe like a rhinocerous on a unicycle :) Just my experience and $0.02. dstn. --- -- Dustin Lang, [EMAIL PROTECTED] -- (java developer, linux guy, green-haired freak) Why Linux is so cool: /usr/include/string.h:190: /* Sautee STRING briskly. */ extern char *strfry __P ((char *__string)); --- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Survey: does this crash your compiler?
Hi,
I've found the miracle handful of lines of code that crash two out of
three compilers I could find *grin*
The contestants:
javac (Blackdown JDK1.1.6v2 on Linux)
javac (Sun JDK1.1.5 on NT)
jikes (on Linux)
sj (the Symantec compiler on WinNT)
The sole survivor:
jikes
Hehehehe :)
dstn.
Caution: compiler death below this line
---
import java.awt.*;
public class DieNow {
public DieNow () {
Panel death = new Panel (null){
public Insets getInsets () {
return new Insets (6,6,6,6);
}
};
}
}
-
Dustin Lang, [EMAIL PROTECTED]
Re: Big-Endians
Hi, > Can someone help me clarify the following: > > Java is Big-Endian, correct? > Intel Linux is Little-Endian, correct? Corrrect me if I'm wrong, but here's my understanding of the endianness: 1. the java classes (such as DataInputStream) do things big-endianedly 2. the jvm is responsible for hiding the endianness of the platform 3. as a result of (2) there is nothing a 100% java app can do to determine the endianness of the platform it's being run on. *shrug* dstn. ------- -- Dustin Lang, [EMAIL PROTECTED] -- (java developer, linux guy, green-haired freak) Why Linux is so cool: /usr/include/string.h:190: /* Sautee STRING briskly. */ extern char *strfry __P ((char *__string)); --- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Big-Endians
Hi, > > 3. as a result of (2) there is nothing a 100% java app can do to determine > > the endianness of the platform it's being run on. > If a Java app exchanges data with data from a non-Java program > then it must face platform-specific endianness issues. > Does a program fail to be 100% Pure Java if it exchanges > data with a non-Java program? (I'm asking, I'm uncertain > of the definition of "100% Pure Java". But, I'd expect > the answer is "no".) There have been a couple of comments on my sloppy use of the term "100% Java". I believe my statement above remains correct, though. From: http://java.sun.com/100percent/checklist.html --- 100% Pure JavaTM Defined: In order to qualify for certification, products must conform to the standards established by the 100% Pure Java Program, which include: 1.No native methods. 2.Depend only on the Java Core APIs. 3.Follow any applicable API protocols. 4.No use of hardwired platform-specific constants. --- Of course, you could write a java app that communicated with a native server via sockets and determined endianness that way, but that would be cheating. :) Just adding to the noise, dstn. --- -- Dustin Lang, [EMAIL PROTECTED] -- (java developer, linux guy, green-haired freak) Why Linux is so cool: /usr/include/string.h:190: /* Sautee STRING briskly. */ extern char *strfry __P ((char *__string)); --- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: newb: running Java service?
Hi,
I'm not certain about any of this, but here are my guesses:
> Is "service" the proper term to use here? ("daemon"?)
Daemon would probably be more appropriate.
> What is "the best way" to do this?
If I'm not mistaken, many (most?) internet-type daemons, ftpd for example,
will fork() a process, allowing the original process to terminate. The
fork()ed process runs in the background.
> I believe the best way to do this is via inetd: is this correct?
inetd does the same thing, except whenever a request arrives, it spawns
the appropriate daemon.
Now, I'm assuming that your backend is java, since you mentioned classes.
In my experience, java is slow to start up, but once it's running it's
okay. If you run your backend through inetd, that means that for each
incoming request, inetd will start up a new java virtual machine. In a
word: ouch! Just imagine you have 50 users at once :)
Probably what would be better would be for it to operate the same way as a
standalone daemon. That way, only one jvm would get fired up and it could
handle each incoming request with a fair bit of speed.
> If so, what would be the proper settings for inetd.conf?
I would guess something like:
stream tcp nowait root /usr/local/java/bin/java
There is, I believe, another alternative that I haven't used and know
basically nothing about: servlets. You can get modules (?) for Apache
that allow it to run server-side java classes. I believe most of them
keep a jvm resident so that handling each incoming request is fast. Look
in the list archives or on the web for "Jserv" or "servlet". Jserv is
just one that comes to mind.
Good luck :)
dstn.
---
-- Dustin Lang, [EMAIL PROTECTED] --
(java developer, linux guy, green-haired freak)
Why Linux is so cool: /usr/include/string.h:190:
/* Sautee STRING briskly. */
extern char *strfry __P ((char *__string));
---
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Ability to reload class files
Hi, Please excuse me for the lack of knowledge obvious in this question; I haven't ever worked with the JVM source. Also, I suppose this applies to all JVMs, but I'm interested in the Linux implementation, because, really, what else is there? :) What I would like to know is this: how difficult would it be to reload the definition of a class if objects of the class had already been instantiated, then destroyed and garbage-collected? As an example, say I'm testing one small component of a large system, and I need to make changes to the small component's class file. Let's say I'm able to make sure that all references to objects of that class have been destroyed and garbage collected. For simplicity let's also say that there are no subclasses of the class. How difficult would it be to allow the JVM to dump its current definition of the class and reload it from the class file, given that the class file may have changed since the JVM was started. java.lang.ClassLoader caches Class objects so that class files don't have to be loaded or resolved more than once. While it would be easy enough to tweak ClassLoader to not do this caching, or to do it more controllably, I have a feeling the JVM might not like that very much. Thanks, dstn. --- -- Dustin Lang, [EMAIL PROTECTED] -- (java developer, linux guy, green-haired freak) Why Linux is so cool: /usr/include/string.h:190: /* Sautee STRING briskly. */ extern char *strfry __P ((char *__string)); --- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
SOCKS firewall piercing?
Hi,
I'm stuck on the bad side of a SOCKS firewall and I'd like to get Java
playing nice with it, at least until I get my Virtual Private Network set
up. The SOCKS 4 protocol is trivial, so I thought I'd just write my own.
However, after a little investigation I discovered that
java.net.PlainSocketImpl actually has SOCKS4 support. The only problem
is, I don't know how to turn it on. *embarassed grin*
I assume it's a properties file somewhere. Here's a relevant code snippet
from PlainSocketImpl:
-
/**
* Returns true if implementation should use the SOCKS protocol
* (i.e. the user has set the required properties to enable SOCKS to
* be used).
*/
private boolean usingSocks() {
String ssp = (String) java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(socksServerProp));
return (ssp != null);
}
-
socksServerProp is "socksProxyHost".
It's probably something really obvious and I feel stupid having to ask.
I've checked the Java side, which of course has a very high noise/signal
ratio. I also checked the archives of this list, and a search for
"socks" turned up three matches - to record-breaking sex that will knock
my _socks_ off. Gotta love the 'net.
Check this out - from the javadoc at the top of PlainSocketImpl. Go
Steve!
* @author Steven B. Byrne
Thanks for your help,
dstn.
----
-- Dustin Lang, [EMAIL PROTECTED]--
(java developer, linux guy, freak with rainbow hair)
User, n.: a particularly slow and unreliable input/
output device that is attached by default to the
standard input and output streams.
(stolen from a Gamelan article, author unknown)
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: SOCKS firewall piercing?
I'll just go ahead and answer my own question and save everyone else the
trouble. Silly Dustin, all you have to do is set a system property. You
can do that like this:
java -DsocksProxyHost=socks.whatever.org -DsocksProxyPort=1080 MyClass
Sorry for adding to the noise... at least this will show up in the list
archives and perhaps the next person won't have to ask the list.
dstn.
> I assume it's a properties file somewhere. Here's a relevant code snippet
> from PlainSocketImpl:
>
> -
> /**
> * Returns true if implementation should use the SOCKS protocol
> * (i.e. the user has set the required properties to enable SOCKS to
> * be used).
> */
> private boolean usingSocks() {
> String ssp = (String) java.security.AccessController.doPrivileged(
>new sun.security.action.GetPropertyAction(socksServerProp));
> return (ssp != null);
> }
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
JNI header files
Hi, It says it can't find typedefs_md.h, and I'd guess that's exactly true. Take a look at the java/include directory. There are a few files and a few directories for machine-dependent code. That's what the _md means. What you need to do is somehow make sure that gcc looks in that directory (something like -I/usr/local/java/include/genunix should work). It's sort of like the linux kernel's 'arch' directory. Cheers, dstn. > I am trying to compile traceroute in c, along with jni.h, and some java > files but keep getting the following error message, anybody any ideas? > Cheers. > > gcc -O2 -DHAVE_MALLOC_H=1 -DHAVE_STRERROR=1 -DHAVE_SETLINEBUF=1 -DSTDC_HEADE > RS=1 > -I. -Ilinux-include -c /home/murray/traceroute-1.4a4/traceroute.c > In file included from /home/jdk117_v1a/include/oobj.h:25, > from /home/jdk117_v1a/include/native.h:26, > from /home/murray/traceroute-1.4a4/jumpDetails.h:2, > from /home/murray/traceroute-1.4a4/traceroute.c:211: > /home/jdk117_v1a/include/typedefs.h:18: typedefs_md.h: No such file or > directory -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
NoClassDefFoundError... argh!
Hi,
My app has recently started throwing NoClassDefFoundErrors. It started
after I made some fairly large code changes, but the errors are coming
from code that was unchanged...
I've removed all the class files and recompiled (hooray for Makefiles!),
with the same result. The only other things in my classpath are rt.jar
and the gnu regular expression package's jar. This should mean that
version skew isn't the cause.
I tried putting try{}catch(Throwable t){t.printStackTrace();} around the
constructors of the classes in question, so I know pretty exactly where
it's happening, but not why.
I just tried recompiling everything with javac (I was using jikes), no
change.
The freaky thing here is that these errors don't get thrown every time.
This error gets thrown in the init phase of the app's life (reading its
config files). Sometimes it dies, sometimes it lives, even given the
exact some config file.
By the way, the class file in question does exist and is in my classpath.
javap finds it just fine. The class contains no static block and no
static variables.
I can (try to) provide any other relevant info.
Am I going crazy?
Thanks for your help,
dstn.
--------
-- Dustin Lang, [EMAIL PROTECTED]--
(java developer, linux guy, freak with rainbow hair)
User, n.: a particularly slow and unreliable input/
output device that is attached by default to the
standard input and output streams.
(stolen from a Gamelan article, author unknown)
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: NoClassDefFoundError... argh!
Hi, > Try to unpack all jars and put them in one tree. If you are using JRE > 1.1.x do the same to rt.jar. Then try to run the app. Jar access code > was not multithreaded at time and sometimes could cause similar effects > (I've experienced it while getting images and classes at same time from > one jar) Hmm, that fixed it right up. Thanks very much for the valuable pointer, Artur. dstn. > Artur -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: NoClassDefFoundError... argh!
Hi, The problem (actually slightly different but feels the same) is happening again. The magical trick of unpacking jars isn't going to work, this time, because my jars are already unpacked :( What's happening is basically that in the initialization of my app I read a config file that contains class names. I've checked several times by several different methods that the class actually does exist. (System.out.println the class name immediately before attempting to load it; cut-n-paste that class name into javap and a little test proggy I wrote. Both find the class no problem.) The exception describes itself as this: java.lang.ClassNotFoundException: java.io.IOException: Bad file descriptor I don't understand :( Thanks for your help, dstn. Here's the stack trace of that exception: at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:185) at sun.misc.Resource.getBytes(Resource.java:71) at java.net.URLClassLoader.defineClass(URLClassLoader.java:245) at java.net.URLClassLoader.access$1(URLClassLoader.java:216) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:191) at java.lang.ClassLoader.loadClass(ClassLoader.java:280) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:275) at java.lang.ClassLoader.loadClass(ClassLoader.java:237) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:124) ...at my code -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: NoClassDefFoundError... argh!
Hi, An ammendment to my original post: The ClassNotFoundException is successfully caught and execution continues (same as it would if a really nonexistant class name was given in the config file), but immediately after it comes the error everyone loves, java.lang.NoClassDefFoundError: MyClass The line the error is coming from (based on the stack trace) contains an array declaration and initialization: int n = whatever; MyClass[] array = new MyClass[n]; A few lines above that, a constructor of the same class succeeds. Hmm. I can provide more info if req'd. Thanks, dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: NoClassDefFoundError... argh!
Hi, > Umm I find that I will get htis error for a class when a class it derives on > is not present. [snip] > Are all the super classes accessible ??? Hmm... The class that's getting the ClassNotFoundException extends the one the NoClassDefFoundError is coming from. In case that was incomprehensible: class A causes the ClassNotFoundException class B causes the NoClassDefFoundError A extends B. B extends java.lang.Object. I can javap both class A and B, so something very strange is happening. Thanks for your help, dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Bad file descriptors?
Hi, Can someone tell me what this means: java.io.IOException: Bad file descriptor at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(Compiled Code) ... This keeps happening while attempting to read an input file I need to use. Thanks, dstn. -- Dustin Lang, [EMAIL PROTECTED]-- (java developer, linux guy, freak with rainbow hair) User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. (stolen from a Gamelan article, author unknown) -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Bad file descriptors and other nasty things.
Hi,
I'm having some real grief with "java.io.IOException: Bad file descriptor"
messages. I'm getting these not only on data file I'm reading (cached web
docs in this case), but also on class files, which causes the
NoClassDefFoundErrors of my previous few posts. I've tried stracing it,
and here's a little excerpt. I'm very very far from a kernel and/or c
hacker, so it's entirely possible I've missed something important. I just
ran my app until one of these happened (didn't take long), did a
System.out.println about it, and matched up the URL that was printed with
the socket calls made (ie, if the URL is /bob and there is a write(18,
"GET /bob ...") call then 18 is naughty one. I then looked back in the
strace for 18 :) Isn't grep great?
There don't seem to be any system calls gone wrong... weird.
Sorry if this isn't very useful... I really want to get this fixed, since
I basically can't do any work until I can run my app. I can try to
provide more info if required.
Thanks,
dstn.
Here's the excerpt:
# Make naughty socket number 18...
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 18
setsockopt(18, SOL_SOCKET, SO_REUSEADDR, [-1], 4) = 0
#snip
fcntl(18, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(18, F_SETFL, O_RDWR|O_NONBLOCK|FASYNC) = 0
getpid()= 3177
fcntl(18, F_SETOWN, 3177) = 0
sigprocmask(SIG_BLOCK, [IO], [])= 0
sigprocmask(SIG_SETMASK, [], NULL) = 0
# connect to the SOCKS proxy server...
connect(18, {sin_family=AF_INET, sin_port=htons(1080),
sin_addr=inet_addr("9.1.40.50")},
16) = -1 EINPROGRESS (Operation now in progress)
select(19, [], [18], [], {0, 0})= 0 (Timeout)
#snip
select(19, [], [18], [], {0, 0})= 1 (out [18], left {0, 0})
connect(18, {sin_family=AF_INET, sin_port=htons(1080),
sin_addr=inet_addr("9.1.40.50")}, 16) = 0
getsockname(18, {sin_family=AF_INET, sin_port=htons(2186),
sin_addr=inet_addr("9.1.23.6")}, [16]) = 0
#snip
# make the SOCKS request...
send(18, "\4\1\0P\234b#\317dustinl\0", 16, 0) = 16
#snip
read(18, 0x418e8fd4, 8) = -1 EAGAIN (Try again)
#snip
select(19, [18], [], [], {0, 5})= 0 (Timeout)
#snip
select(19, [18], [], [], {0, 5})= 1 (in [18], left {0, 5})
#snip
select(19, [18], [], [], {0, 5})= 1 (in [18], left {0, 5})
#snip
# read the SOCKS response...
read(18, "\0Z\0\0\0\0\0\0", 8) = 8
#snip
setsockopt(18, IPPROTO_TCP1, [1], 4)= 0
#snip
# Make the HTTP request (a page about tree frogs)
send(18, "GET /fish_and_wildlife/frogs/tre"..., 165, 0) = 165
#snip
read(18, 0x418e9140, 2048) = -1 EAGAIN (Try again)
#snip
select(19, [18], [], [], {0, 5})= 1 (in [18], left {0, 5})
#snip
select(19, [18], [], [], {0, 5})= 1 (in [18], left {0, 5})
#snip
# Read the HTTP response (500 bytes total)
read(18, "HTTP/1.1 200 OK\r\nDate: Fri, 23"..., 2048) = 500
brk(0x89eb000) = 0x89eb000
brk(0x89ef000) = 0x89ef000
brk(0x89f3000) = 0x89f3000
brk(0x89f7000) = 0x89f7000
ioctl(18, FIONREAD, [0])= 0
ioctl(18, FIONREAD, [0])= 0
# Exception is thrown here.
# System.out.println the exception
write(1, "Cache: Uh oh: java.io.IOException: Bad file descriptor") = 54
-- Dustin Lang, [EMAIL PROTECTED]--
(java developer, linux guy, freak with rainbow hair)
User, n.: a particularly slow and unreliable input/
output device that is attached by default to the
standard input and output streams.
(stolen from a Gamelan article, author unknown)
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Drag'n'drop?
Hi, I keep getting this in my DnD code: java.awt.dnd.InvalidDnDOperationException: The operation requested cannot be performed by the DnD system since it is not in the appropriate state Isn't that a great generic error message? Gotta love it. Does anyone know what causes this, or how to fix it? It used to happen only sporadically, but now seems to happen every time with my code :( I've tried decompiling the sun classes that are throwing this exception and seeing what's actually happening, but with not much success so far, since it tends to go native fairly quickly. Thanks for any tips, dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- (java developer, linux guy, freak with rainbow hair) User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. (stolen from a Gamelan article, author unknown) -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Cut-n-paste?
Hi, I've been trying to get cut-n-paste working in my application (drag-n-drop works nicely, at least intra-vm). Doing a copy from netscape (via the Copy menu item) works (pasting into a textfield using CTRL-V), as does copying from my app to netscape (via a popup menu on the java side and the Paste menu item on the netscape side). While this is good, what I'd really like is to allow copying by highlighting, and pasting by pressing button 3, the way xterm, netscape, and other apps do. I searched the archives and found some discussion about this and it seemed the problem related to there being at least two different clipboard buffers. This seems to make sense, and java seems to be able to use one type (the CLIPBOARD clipboard?), but not the other (a cut buffer?). Has anyone had any success or failure with button 3 pasting? Care to share your findings? Thanks, dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: File or class transfer over tcpip
Hi,
> needed. It works like a charm but, the typical but word my classes when
> used by the JVM either through security exceptions or are unreadable. To
> transfer the class file we are using the following:
[snip]
> DataInputStream di = new DataInputStream(new
> FileInputStream(new File(loc)));
> int avail = di.available();
> System.out.println("Available: " + avail);
> byte[] data = new byte[avail];
> di.readFully(data);
I'm afraid it's an RTFM. available() tells you how many bytes can be read
without blocking. This is NOT necessarily the size of the file. You're
probably sending the first 1k of each file to your clients. The class
file will then of course fail during loading.
Just a guess,
dstn.
PS - I wrote an app that does something like this (transferring file via
RMI), and I would suggest that you be extremely careful about path
separator characters.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
[Off-topic] Drag-n-drop applet?
Hi, I've been working on an application that uses the drag-n-drop features of Java2. I'm interested in converting it to an applet because it deals with HTML and the web. Besides security issues, one of the big problems is getting drag-n-drop. DnD was only added in jdk1.2, and all the browsers out there seem to only support jdk1.1. The Java Plug-in seems to be available for winders, but using winders is clearly not an option :). I even checked out HotJava in the hopes that it would run 1.2 applets, but HotJava doesn't even run in 1.2. Gotta love Sun. I've been thinking of ways to get around using DnD, but it's sort of integral to the way I designed the interface. Argh! I'm going to look into doing my own pseudo-DnD for intra-JVM transfers (which is all I want to do anyways). I'll probably have a mouselistener that listens for drag events and uses some sort of static clipboard class to transfer stuff. I'm not sure how well this will work, though... Does anyone have suggestions/ideas/comments? Thanks, dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: native/green
Hi, > I know I have seen this here before. What does it typically mean if my > java app runs with native threads, but not in green threads (117_v3)? Green threads follow the java threading specifications. In particular, they don't guarantee time-slicing, which a lot of threaded code incorrectly depends on. Your threading might be broken. What happens when you run your app? Is the JVM crashing, or is your app breaking? dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: [Off-topic] Drag-n-drop applet?
Hi, I'll just answer my own post in case anyone else is interested. I wrote a little Drag-n-drop handler for JDK1.1. It just does intra-jvm dnd, but that's all I need anyways, and as far as I can see doing anything would require native code. I made an interface for components that want to do Dnd with methods like dragStarted(), dragCancelled(), dropCheck(), and dropPerformed(), and then the DnD handler can just detect drags, watch for drops, and then ask the source and target if they want to do a drop. Simple. When a drop happens (which is just a mouseReleased event), you just have to figure out which component the drop happenend in. Easy. dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Background processes?
Hi, Can anyone tell me if there is a way to Runtime.exec() a process that lives longer than the Java process that spawns it? How obvious is it that I'm not a (real) C/Unix programmer? ;) Thanks, dstn. -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Jozilla?
Hi, > I downloaded the user version but since it runs on 1.1 I > decided to upgrade the lot to 1.2 myself. I've found that unless there's a good reason to use 1.2 (ie, one of Sun's 1001 APIs that is only in 1.2), there is no really good reason to "upgrade" from 1.1 to 1.2. It may not be a bad idea to see if it compiles and runs in 1.2, fix any deprecated stuff in a 1.1-compatible way, and leave it at that. If there are large sections of code that could benefit from some of the new stuff in 1.2, then it may be worthwhile, but the "upgrade" should not be undertaken blindly and solely in response to keeping up with the latest version number. More bells and whistles may not make the product better, they make just make it louder. :) Just my experience, dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Drag and Drop
Hi, > I am new to Java programming. > I would like to know is it possible to drag and drop buttons or > picturebox from one location to another? Also, it is possible to draw a > line and have the line respond to a mouse click? In Java the language, compilers, runtime, and development tools are all separate entities. I've never used VBasic (yuck!), but assume that at least two of those are integrated. You're not looking for a Java book, you're looking for a visual or integrated development environment. Search the archives for IDE. There are several available; it's also possible to do without a visual development environment (that's what I do). Cheers, dstn. -------- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Out of Memory Problem!!! Urgent!!!
I'm not surprised. You're allocating 20 megs for your program. This is not much. I'm not surprised you're running out of memory. I'd suggest using a higher value. > java -mx2k xxApplication -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
RE: Applet transparency?
Hi, > Try setting the background color to null. One might suppose that what should happen is that the browser would leave the background in its original pristine state, and then unless the applet painted itself, that background would stay the way it was. I think most (read: all) browsers paint the applet with some default colour (ugly gray?). An alternate solution would be for the applet to ask the browser what the background looked like originally. This could/would be done through AppletContext. Alas, such a method does not exist, so you're pretty much out of luck, at least in the general case. It's important to make the distinction between actually making the applet transparent and making it look transparent. As far as I can see in general, the first is not possible, while the second is relatively easy. Cheers, dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Api Linux
Hi,
Be careful - that code snippet can cause deadlock, ie, execSystemCommand
will never return, at least on some systems. This is caused by an
undocumented "feature": there are output streams coming from the Process
object, and if these streams' buffers fill up, execution will stop until
someone else reads bytes from the streams. Since in your code snippet
there is nobody reading from these streams, deadlock can occur.
Cheers,
dstn.
> I think the following method may be useful:
>
> public int execSystemCommand(String cmdLine)
>throws InterruptedException {
>Process p = Runtime.getRuntime().exec(cmdLine);
>return p.waitFor(); // by convention '0' means normal termination
> }
--------
-- Dustin Lang, [EMAIL PROTECTED]--
User, n.: a particularly slow and unreliable input/
output device that is attached by default to the
standard input and output streams.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: JNI link to disk space
Hi, > > > I am interesting in getting the disk space and partition > > > in a Java program by using JNI. What is the std UNIX API > > > call to do this? I have tried grepping the man pages > > > and got the source to kdf program but it didn't help > > > because it was executing `/usr/bin/df -k -T' and parsing > > > the output. Is there a native portable UNIX system call that > > > provides partition information and also disk space size and free > > > information? I'm working on an installer that also needs to find out this information. IBM Alphaworks has an Install Toolkit for Java that includes some classes for doing this sort of thing. For UNIX/Linux they just call df and parse the output. Sure, it's an ugly solution, but if it works and saves you from writing some irritating parsing code... If you find out or invent a better way (perhaps via JNI, as you originally suggested?), and you are able to release the source, I would be most grateful to see it! :) Cheers, dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Version snag
Hi,
> I am just surprised that the software now states that the pre-release
> 2 is not JAVA 2, can anyone make a suggestion as to why?
I would suspect that your program is checking for a version number string
in a particular format, and is not receiving an answer in precisely that
format, and is choking. I would further suspect that it was written in
windows and not tested anywhere other than windows. Blah. I would also
suspect that your code is calling System.getProperty("java.version"), and
calling something like "1.2".equals(System.getProperty("java.version")).
This would sugest that your code is to blame, not the Blackdown JDK (and
your message is therefore off-topic). I cannot make a further guess
without seeing your code.
Cheers,
dstn.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: A Java parser
Hi, > Suppose I want to do a tool that parses the java code and modifies it. You could take a look at Jikes. It's open source, and I've heard of people using Jikes to parse code and then do something instead of compiling it. Of course, it's written in C++, so if you want to write your parser in Java, then you'll either need to do some JNI, or maybe port their parsing code from C++ to Java. By the way, your .sig is way huge. Though impressive, it's kind of annoying. :) Cheers, dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Do we need an installer-chooser?
Hi, Despite the pretty decent web documentation, this list seems to be inundated with question of the form "I'm running and I'm getting ", or "I have . What file do I need to download?". I was thinking that it should be possible to write a little piece of C code that would check the person's distribution and libc library versions, and suggest the appropriate distribution file to download. At that point it could also print out a list of the known issues with that particular dist/version, and suggest any other setup steps that might be required (ie, add /usr/local/java/bin to your PATH, and so on). Such an app might make the install process a little less mystifying for newbies, and thereby reduce the number of silly questions asked on this list. Furthermore, I was thinking that I don't have much to do this weekend and that my C skills are getting crufty. Do people think this app would be useful? Any pointers/suggestions? Thanks, dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Do we need an installer-chooser?
Hi, > perhaps if this could be embeded in a web page... an applet? that would > be cool. > and unless you plan to compile to all archs maybe a shell script > would be better? Hmm... I was thinking a smallish, statically-linked C program. I hadn't thought about multiple architectures (I'm a little Intel-centric...:). I have access to Intel and PowerPC boxes and could supply binaries for those archs. I'd GPL this if I wrote it, so could distribute source for other archs, but that might make the process even more puzzling :). I was thinking of doing it that way because: -I suck at shell scripts -I don't suck quite as much at C. -I want some practice in C. -Some of the checks might be hard to do in shell scripts (haven't thought about this much; I'm sure it would be possible, but probably hard for someone as lacking in skill as myself :) > if it based all of it's decisions on files in a > standard location on the ftp server then it could be updated auto- > magically. That would be cool. Good plan. > equally interesting would be to do a ping of the mirrors and > download from the closest first. Cool idea! Thanks, dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Do we need an installer-chooser?
Hi, > Why not use a javascript check on the web page, saying here is the > archive for your specific platform? ( In addition to links to the > others if you also grabbing the versions for other platforms. ) The big piece of information we need is (g)libc version. I'd be impressed if there was a way to find that out with javascript... and a little worried considering the filesystem access you'd need to find that out... Cheers, dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Chooser
Hi, I think I'm going to go ahead with trying to write a little C program to check which library versions a system has and give the user some suggestion about what JDK file she should download. In order to do this, I need some information about where systems keep their libraries and identifying files. Both my Slackware ~4 and LinuxPPC (based on RedHat 5.0) boxes keeps their libs in /lib and /usr/X11R6/lib. I think that if I check the same directories as 'ldconfig', that should suffice. Comments? If possible, I'd like to check and see if I can figure out what distro and version the user is running, so that if I know of a package made for that distro, then I can suggest it as a possibility (eg, if we're on a RedHat system and there's an rpm, suggest it). But then, what about programs like alien that can convert between package formats? Should I just suggest "native" packages? Or perhaps have a command-line switch to optionally display everything available that matches the library versions available (and architecture, of course:). Are there packages of the blackdown JDK for the various distributions? In the mailing list archives I see several references to an RPM that can be found in the contrib section, and a search of the Debian package listing shows it can be found in the non-free section. Do any other distributions have packages available? Thanks for your input, dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Off-topic: OS/arch combinations
Hi,
I'm going to perform an act of hypocrisy here, by posting an
off-topic question, after mildly flaming others for doing the same... so
shoot me :)
I'm working on an installer for a Java program we're distributing. I'm
bootstrapping: running Java off the installation CD to install itself. I
need to find out the system's OS/arch combination to choose the correct
JDK to install. I want to cover as many combinations as possible, but to
do so I have to detect each type. I've tested my code on as many machines
as I have access to, but any others people could help me out with would be
great.
I'm simply fetching the System properties "os.name", "os.version" and
"os.arch" and decoding them appropriately. If your system spits back a
string different than the ones listed, I'd like to hear about it.
os.name values I've encountered:
Linux
Solaris
SunOS
Mac OS
Windows NT
Windows 95
(Note: it seems that Sun's JDK, at least, spits back "Windows 95" for 95
and 98 systems, while os.version are set to "4.0" and "4.10", resp.)
os.arch values I've encountered:
x86
ppc
PowerPC
sparc
Thanks very much for your help,
dstn.
-- Dustin Lang, [EMAIL PROTECTED]--
User, n.: a particularly slow and unreliable input/
output device that is attached by default to the
standard input and output streams.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Installer chooser
Hi, A little while back I was talking about writing a program to check a user's system and from that information decide what JDK version they should get. I was being stubborn about writing it in C, but I got over that fairly quickly :) I'm now working on a shell script that looks at libc versions. I've gotten to the point where I have to start adding some brains: some actual information about what JDK version is recommended. There are a few things I need to know: -The README in the JDK I have on my local system says that if the person has both libc5 and glibc, they should grab the glibc, but libc5 should work also. Based on my own experience, where I hand-upgraded glibc and kept libc5 around also, this is true. Any counter-examples? -Do you suppose I should suggest the JDK that depends on the highest compatible (g)libc version? This seems reasonable to me, but there may be reasons to not do so... -I was planning to find out if the user is running a certain distribution and version.. So far I have information about a couple of systems I have contact with. RedHat seems to put a file "/etc/redhat-version" with text like "RedHat 5.0 (Hurricane)". Debian seems to have a file "/etc/debian_version" with text like "2.1". (I'm doing this from memory, so I could be slightly wrong). As far as I can see, Slackware (at least the versions I run - old) has no particular identifying marks that are easy to find. If people want to provide me with additional information about distributions that have particular identifying marks and available java packages, send me the URL of the package and how to identify the distribution. My basic plan is for the final output to be something like this: You are running an ix86 system with libc5 and glibc2 installed. Your glibc version is 2.0.7. You appear to be running Debian 2.1. Based on this information, I would suggest these JDK 1.1 packages, in this order: ftp://ftp.debian.org/blah/jdk-1.1.8-blah-.deb ... If you're the sort of person who likes to grab source and compile it yourself, you're out of luck in this case, (Sun SCSL == evil) but you can grab these tar-gz binaries: ftp://metalab.unc.edu// ... As for JDK 1.2 (Java 2) packages, here's what you should grab: ftp:// And for JDK 1.2 (Java 2) tar-gz binaries: ftp://... Have a ducky day! Should I bother mentioning JDK 1.0 ? In each major JDK version, I was planning to list both packages, if available, or tar-gz binaries. I would list the native package format first, and then any other compatible package formats (eg, for Debian, list .deb and then .rpm and others that "alien" can read). I'd also like to make a quick check for possible pitfalls that show up on the mailing list a lot. For example, check if the person has X installed, if not, suggest virtual framebuffer if they need to use AWT for server-side stuff. Also, maybe check XF86Config for problems with incompatible color depth? Any other suggestions for pitfalls to check for? Should I be checking other libraries required by the JDK like libXpm and other X libs? Thanks for your input! dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: text field display bug
Hi, I assume you know how naughty absolute positioning is. Ten lashes with a wet noodle for you. It sounds as though you're assuming that the text is a certain size, and that it is actually a different size. If you're not using FontMetrics, you should be. Without more information, it's hard to say what's going on :) Cheers, dstn. > We're having a really difficult time properly displaying text within a > text field using the standard dialog font. For some reason, the text > within the text field gets pushed down such that only the very tops > of the characters are visible. Under MSwindows there are no > problems. We also are not using a layout manager, only absolute > positioning... Any suggestions? > > We are using Caldera 223 and jdk1.2.2 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: current directory
Hi,
> how can I get current directory in servlet?
This is not Linux-specific, or even servlet-specific, for that matter.
There is a trick, though it feels like bad programming form:
new File(".").getAbsolutePath();
In the future, you would do better by finding a more appropriate forum for
questions that are not specific to the Linux JDK(s).
Cheers,
dstn.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: how to extract .tar.bz2 ?
Hi, > I download Blackdown jdk1.2.2: > > jdk-1.2.2-RC3-linux-i386.tar.bz2 > > I can not use "tar xvfI jdk-1.2.2-RC3-linux-i386.tar.bz2" > command in linux # prompt. Anyone help me ? If your tar program is older, it will not know about bunzip2, ie, it will not understand the "I" option. You alos need the bunzip2/bzip2 program(s) installed. If your still have problems after checking out these possible problems, contact me off-list, and be sure to include specific error messages you encountered. Cheers, dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Y2K readiness.
Hi, > I've looked all over blackdown.org for a y2k statement, but > I've found none. Any of you know if there are any y2k issues with > the blackdown ports? (specifically jdk117_v1a). I'm not a member of the porting team, but I can tell you what I think they would tell you. The JDK, like almost any reasonable piece of software, relies on the system libraries for dealing with time values. Therefore, the JDK relies entirely on the OS to give it reasonable time values. The OS, in turn, likely relies on a hardware clock, at least at system startup time. Since Java generally deals with time values in terms of milliseconds since Jan 1 1970, the date Jan 1 2000 is of no special significance. I can tell you what the value is if you really want to know, but it's pretty much as non-interesting as any other millisecond. So the question really becomes, come Jan 1, what is your OS going to tell the JDK the time is? There should only be problems if your hardware clock stores only 2 digits of the year. I'm by no means a Y2K authority, this is just what common sense tells me. I haven't checked if my own h/w clock is going to work, and frankly I don't much care. If it breaks, I'll fix it. Cheers, dstn. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Jar file with JDBC
Hi,
> try
> {
> Class.forName("postgresql.Driver");
> db = DriverManager.getConnection(url, usr, pwd);
> st = db.createStatement();
> }
> st.executeUpdate(crt);
>
> //While executing this statement it gives nullpointer
It looks as though the driver can't create a statement, since
"st" is null. Are you sure you are including absolutely all the classes
required by all parts of your application and your jdbc driver? To test
this specifically, try putting all the classes you use in one base
directory, then set your path variables and make sure that classes are
being only loaded from there and rt.jar. Then jar that directory and see
what happens!
Another option might be turning on verbose class loading to see what's
happening.
Both these ideas should help to detect class loading, which by your
description sounds like the base of your problem, since it works out of
the jar.
Cheers,
dstn.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
DatagramSocket and Thread problem
Hi, I checked the archives but didn't find anything that sounds like this... For a homework assignment I have to write a datagram-driven client and server pair. They are meant to be used by higher-level classes to handle the underlying communication. The client sends out numbered requests and waits for matching numbered responses. In order to handle multiple simultaneous requests, I have given the client a dedicated receiving thread. When a request is made, the requesting thread sends a packet from a DatagramSocket, adds itself to the list of waiting threads, and goes to sleep. When the receiving thread receives a matching response packet from the server, it wakes up the sleeping client. All this information is a bit extraneous, but the point is this: there are multiple threads using the same DatagramSocket for sends and receives. I was under the impression that this was a valid and reasonable thing to do. With JDK-1.2.2-FCS, I get strange behaviour. It seems that the receiver thread is okay until the sender thread does a send() on the DatagramSocket that the receiver is receive()-ing on. When this happens, the receiver thread gets a "SocketException: socket closed" exception. This seems strange because I did not connect() the socket, and I never call close() in my code - the socket gets reused. I created a smallish test class that demonstrates the behaviour. I ran it on a Solaris box and got the behaviour I think is correct. A small tarball containing the test source, output from running on my machine and the Solaris box, plus version information from the two JDKs is available: http://taz.cs.ubc.ca/~dustinl/socket-test.tar (By the way, the output is of the form "[ ] ". ) This is on kernel 2.2.19, libc 2.1.3, jdk 1.2.2-fcs, native threads/sunwjit and green threads. Thanks for your help! dstn. -------- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
DatagramSocket and Thread problem (more)
Hi again, Further to my previous message. It seems that the sending thread is also bothered by the receiving thread. The first send() succeeds, but once the receive thread touches the socket, all further send()s fail with "IOException: Connection refused". This is a DatagramSocket! I was under the impression that this exception should never be thrown by DatagramSocket.send() - packets are just sent off into the big blue yonder; if nobody is listening on the destination machine, the packet should just get tossed into the bit bucket. Any suggestions would be appreciated. Cheers, dstn. ---- -- Dustin Lang, [EMAIL PROTECTED]-- User, n.: a particularly slow and unreliable input/ output device that is attached by default to the standard input and output streams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: DatagramSocket and Thread problem
Hi, > I have edited your code. It is working fine, except for few changes. Thanks. However, my original email was essentially a bug report, not a request for help with my code. I didn't actually say "bug report" because so many bug reports end up just being problems with people's code. I believe my code as originally posted was valid (and reasonable!) and that the Blackdown Linux JDK is doing something wrong. The changes you made are the obvious ways to work around this bug. However, there are some remaining problems. You changed socket = new DatagramSocket(); to socket = new DatagramSocket(2000,InetAddress.getLocalHost()); where you have arbitrarily chosen port 2000. I really do want the correct behaviour of the argument-less DatagramSocket() constructor: to pick an unused port. It would be possible to, starting at a random number, look for an unused port, but this is ugly when a constructor that does exactly what I want already exists. > The sender to the same port you are listening to else you will get a time > out error. If I wanted to talk to myself. :) This of course not the point of the exercise. The address I chose for the send() was completely arbitrary. For my application, it will be the address of the server, of course. > Instead of socket.getLocalAddress().getHostAddress() use InetAddress. > getLocalhost(). The former gives 0.0.0.0. Yes, I noticed. If I wanted the address of the local host, I would use InetAddress.getLocalhost(). What I wanted to demonstrate in my small test class was the behaviour of DatagramSocket.getLocalAddress(). The Linux JDK behaviour in this case actually matches the Solaris behaviour. 8-) > These make the program work successfully. By working around the problem. This email might sound rude - it's not meant to be! I'm just pointing out that you're showing me how to work around what I believe is a bug, without addressing whether it actually is a bug, or addressing what to do to fix the bug. After writing this I checked the bug database at java.sun.com. There were several reports of this happening in some flavours of Windoze and one flavour of Redhat. They claim to have fixed the problem in Merlin aka 1.4. The solution is thus simple: wait! Thanks for your response! Cheers, dustin. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
