• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

OOP-1 (DaysOld): setting classpath

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Diego Klappenbach
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

CLASSPATH=.;c:\short\path\foo.jar;"c:\Program Files\Apache Group\ETC\servlet.jar";c:\another\short\path.jar

Also, you show us what command works
(javac DaysOld.java -classpath foo.jar )

But not the command that doesn't work... What is the exact command (and from what directory) that you send to javac
[ October 22, 2003: Message edited by: Mike Curwen ]
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

Regards, Andrew
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"?
 
Diego Klappenbach
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Diego,

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:

Regards, Andrew
 
Diego Klappenbach
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
a wee bit from the empire
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic