• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HELP with classpath please

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your class in a package?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic