Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java-execution only works if CLASSPATH is empty - why???

 
Robert Jaeger
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
This is a weired thing.
If I set
CLASSPATH j2sdk1.4.0_01\lib\tools.jar
the execution of test.class (which I successfully compiled from test.java) doesn�t work (The class cannot be found!)
If I leave the CLASSPATH empty, it works!!!
That is weired.
Unfortunately I want to add jdom.jar to my classpath, if I do that the execution of test.class doesn�t work anymore.
Another problem/question: Where do I have to put jdom.jar that it can be found? I put it in c:/j2sdk1.4.0_01/lib, but during compilation the packages that shoud be imported cannot be found.
Weired, too!
Someone can help me?
 
Marilyn de Queiroz
Sheriff
Posts: 9079
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set your classpath to the subdirectory that contains your class after you compiled it with javac.

So if you have a subdir like C:\java that contains MyClass.java and you compile it with

javac MyClass.java

then you now have C:\java\MyClass.java and C:\java\MyClass.class

Your classpath should include C:\java

You can add a jar file to C:\j2sdk1.4.0_01\jre\lib\ext
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!