• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HELP with classpath please

 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I'm having a big issue on attempting to run my class through command line, here's what is going on.

I have all the necessary libraries in the same directory as my class file, so what I do is:

javac NovoTestGet.java

then,

java NovoTestGet

and I get the following:



I really wish someone could help me out on this one,

Regards.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've probably got the CLASSPATH environment variable set, but it's set to a value that doesn't include "." (dot), the current directory. The best thing to do is unset the CLASSPATH variable, and use the default, which is, in fact, ".". But you can also specify the class path on the command like:

java -classpath . NovoTestGet

(That's java space dash classpath space period space NovoTestGet).
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedman-Hill wrote:You've probably got the CLASSPATH environment variable set, but it's set to a value that doesn't include "." (dot), the current directory. The best thing to do is unset the CLASSPATH variable, and use the default, which is, in fact, ".". But you can also specify the class path on the command like:

java -classpath . NovoTestGet

(That's java space dash classpath space period space NovoTestGet).


Thank you so much for the quick reply, but unfortunately I still got that error... I did just what you said, set the environment variable as ".", and I got all the jars I need to run it in the same directory of my java class, so I did:

java -cp . NovoTestGet

and still didn't work... then I tried:

java -cp .:commons-httpclient-3.0-rc4.jar:commons-codec-1.3.jar:commons-logging.jar NovoTestGet

but nothing

any other hint?

Regards.
 
Henry Wong
author
Marshal
Pie
Posts: 21490
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your class in a package?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a class named NovoTestGet in NovoTestGet.java ?

If you ask for a file listing of the current directory (i.e., "dir" on Windows, or "ls" on an actual computer) do you see NovoTestGet.class ?
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:Is your class in a package?

No it's not. here's my java file, and the jars are in the same directory as my class file:

 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedman-Hill wrote:Is there a class named NovoTestGet in NovoTestGet.java ?

If you ask for a file listing of the current directory (i.e., "dir" on Windows, or "ls" on an actual computer) do you see NovoTestGet.class ?


Yes, I do.

16/10/2009 10:42 <DIR> .
16/10/2009 10:42 <DIR> ..
10/07/2004 17:13 46.725 commons-codec-1.3.jar
10/10/2005 23:08 278.799 commons-httpclient-3.0-rc4.jar
23/07/2004 14:14 31.605 commons-logging.jar
16/10/2009 10:41 1.592 NovoTestGet.class
16/10/2009 10:40 1.116 NovoTestGet.java
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gustavo Santos wrote:
java -cp .:commons-httpclient-3.0-rc4.jar:commons-codec-1.3.jar:commons-logging.jar NovoTestGet

So you're not on Windows? I'm asking because Windows uses semicolons for the classpath delimiter, not colons.
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
Gustavo Santos wrote:
java -cp .:commons-httpclient-3.0-rc4.jar:commons-codec-1.3.jar:commons-logging.jar NovoTestGet

So you're not on Windows? I'm asking because Windows uses semicolons for the classpath delimiter, not colons.


Yes! I GOT it! thank you guys for your help! I just needed to change the ":" with ";" ... didn't know the difference between both, very silly.

Many thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic