Hi all, I get the following compiler error message
when trying to compile
I've read all relevant previous posts regarding this and followed all suggestions stated there, e.g. downloaded the .zip file a couple of times just in case it got corrupted during download, rebooted four times after trying different classpath settings, etc. etc. etc.... I think I'm entitled to give up now. I suppose one special thing is that I have all my java stuff in a USB memory stick that I carry around. Coding, compiling and running of code then takes place on two different machines (both running Windows 2000). That worked fine up to now, so I don't think the problem lies here. Rather, I think it has something to do with setting my classpath. Actually, up to now I didn't have any classpath environment variable (just JAVAPATH and PATH). Following a link on one of Marilyns old posts, I created and set it to
(J: is the name of the USB drive.) The JavaRanchCommon.zip file and the DaysOld.java file are both in J:\. I've run out of ideas to try. Does anybody have some to spare?? Cheers, Diego PS. "Two PATHs diverged in a PC, and I, I chose the PATH less traveled by, and that has made all the difference." ...or something like that..
Chicken Farmer ()
Joined: May 08, 2001
Hrm, a couple of suggestions to see where the problem may lie. First, I'm not sure if it matters but the class path env variable is usually all caps, so CLASSPATH instead of ClassPath. Second, it's generally good practice to put the . first, so CLASSPATH=.;j:\;... Third, try putting the zip file on the c: drive and see if that works (add it to the class path of course), and see if that works.
Joined: Aug 29, 2003
Jason, I tried your three suggestions. The classpath is now set to: CLASSPATH=.; C:\j2sdk1.4.2_01\lib; c:\test\; c:\test\JavaRanchCommon.zip; and the .zip and DaysOld.java files are of course in c:\test\ . Unfortunately, that didn't help much. But, here's another test that may give a clue (i.e. someone else, not me...). A friend of mine running a Linux machine just took the "com" folder (one of the folders you get when unzipping the JavaRanchCommon.zip file) and created the .jar file "foo.jar" out of it. This .jar file is put in c:\test\ where the DaysOld.java file is. The classpath is left unchanged (i.e. as above). If I now run javac DaysOld.java -classpath foo.jar , the damned thing compiles without problem! BUT ONLY when I use HER foo.jar! When I create my own foo.jar, it doesn't compile anymore! Maybe the problem is not the classpath but something else? [ October 22, 2003: Message edited by: Diego Klappenbach ]
It might just be your typing it with spaces, so we can see it better here, but CLASSPATH should contain no spaces at all, and if there is a long file name with spaces, surround the entire entry in double quotes:
Hi Diego, In your example that worked, you specified the location of <code>foo.jar</code> as a parameter to the <code>javac</code> command. Could you try the same thing with the original <code>JavaRanchCommon.zip</code> file? Further to Mike's comments, I would suggest you copy and paste all the commands you type into the command line prompt for both working and non working commands. Copying and pasting the commands is preferable to retyping them. For an example, here are the commands I just tried:
So you can see my initial attempt failed, but defining the location of the zip file in either the CLASSPATH or as a command line parameter worked. Or, under Linux:
If you go to the command prompt, what is the size (in bytes) of the JavaRanchCommon.zip file that you downloaded? If it isn't 184,776 I'd guess that you got a corrupted file. Did you right-click and "save-as"?
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Aug 29, 2003
Marilyn, Did you right-click and "save-as"? Yes. ...what is the size (in bytes) of the JavaRanchCommon.zip file that you downloaded? 184,776 bytes. Mike, ...CLASSPATH should contain no spaces at all.. Thanks for the tip, now it works in the c: drive (but not in the j: drive) :
Andrew, In your example that worked, you specified the location of foo.jar as a parameter to the javac command. Could you try the same thing with the original JavaRanchCommon.zip file? Yep, that works, thanks:
but as above, it does not work in the j: drive :
Am I simply setting the classpath for the j: drive wrong? Or does the system handle removable disks like my USB memory differently than the c: drive?
author and jackaroo
Am I simply setting the classpath for the j: drive wrong?
I cant see anything wrong with what you are doing. By the way - you don't need to set the <code>CLASSPATH</code> and specify the <code>-classpath</code> parameter: either of those two options should work.
Or does the system handle removable disks like my USB memory differently than the c: drive?
At an application level (and javac is an application) the removable drive should appear to be just another drive. There shouldn't be anything special about it. What do you get when you run the following command:
Joined: Aug 29, 2003
Andrew, great tip, here's the output:
Now I saw that the .zip file in the J: drive could not be found! Why? I checked and the difference was that the .zip file in J: was named whereas the one in the C: drive only ! After renaming the J: .zip file (in Windows Explorer) :
It works! Thanks a bunch you all! Regards, Diego [ October 23, 2003: Message edited by: Diego Klappenbach ] [ October 23, 2003: Message edited by: Diego Klappenbach ]
Joined: Jan 19, 2001
Originally posted by Diego Klappenbach:
PS. "Two PATHs diverged in a PC, and I, I chose the PATH less traveled by, and that has made all the difference." ...or something like that..
lol That sense of humor comes in handy when you're working through the Cattle Drive, whatever path you take...