CLASSPATH help
I cannot get my classpath set right apparently. (I've already searched and read the other topics) I can compile and execute through JCreator, but I cannot do it through the command prompt. Please help. Errors I get:
I compiled correctly, but when I try to execute, I get this
C:\Documents and Settings\Robbie\My Documents\java>java MakingChange.class
Exception in thread "main" java.lang.NoClassDefFoundError: MakingChange/class
C:\Documents and Settings\Robbie\My Documents\java>java -showversion
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
classpath is .;C:\j2sdk1.4.2_05\jre\lib\ext
PATH is C:\j2sdk1.4.2_05\bin
[792 byte] By [
thelopper] at [2007-9-30 17:56:36]

This time I got
C:\Documents and Settings\Robbie\My Documents\java>java MakingChange
Enter purchace price
$Exception in thread "main" java.lang.NoClassDefFoundError: cs1/Keyboard
at MakingChange.main(MakingChange.java:12)
cs1.Keyboard is in my input class (cs1.jar) and is located in C:\j2sdk1.4.2_05\jre\lib\ext which is in my class path
> When you use the "java" command you are supposed to
> use the name of the class, not the name of the file.
> In this case the class is called MakingChange, so the
> command should bejava MakingChange
That is what I did and got an error, it is in the post above yours. (sorry, I forgot ito include it in my first post)
> I wonder if C:\j2sdk1.4.2_05\jre\lib\ext\* will work
> too. *goes to try*
It won't. Please read these:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
You should not have to set up class path if you put a library in jre/lib/ext. You must have a JRE installed that you are not aware of and use it for running your program instead of the one in C:\j2sdk1.4.2_05.
You can get rid of the problem by copying cs1.jar to the lib/ext directory of that other JRE and by rearranging your PATH environment variable so that C:\j2sdk1.4.2_05\bin comes before any other directories.
> You should not have to set up class path if you put a
> library in jre/lib/ext. You must have a JRE installed
> that you are not aware of and use it for running your
> program instead of the one in C:\j2sdk1.4.2_05.
>
> You can get rid of the problem by copying cs1.jar to
> the lib/ext directory of that other JRE and by
> rearranging your PATH environment variable so that
> C:\j2sdk1.4.2_05\bin comes before any other
> directories.
No, that is the only one. Plus when I type java -showversion, I get this
C:\Documents and Settings\Robbie\My Documents\java>java -showversion
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04) <<<look here
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)>
> No, that is the only one.
Try searching your harddrive for "java.exe" -- you'll probably find several. At least in c:\j2sdk...\bin and c:\program files\j2re...\bin. The java.exe that you run from command line comes from the latter and the lib/ext directory of that JRE does not contain cs1.jar