java.lang.NoClassDefFoundError
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
Quite often, I find any attempt to articulate the precise problem I am having while coding will usually send me down the right path. Asking questions and sticking to the problem in an attempt to solve it is far more preferred here than the usual: "it won't compile, plz hlp? k thx"
I choose to fight with a sack of angry cats.
Need help with J2EE SDK 5.0 & TextPad on Windows XP?
Need help plugging in your SDK 5.0 commands into TextPad tools? Hopefully what worked for me will work for you.
I recently downloaded Sun's AppServer bundle including SDK 5.0 to C:\Sun\AppServer. I then downloaded TextPad.
Unfortunately for me, Configure>Preferences>Tools --> Add did not automatically show "JAVA SDK Commands", so I added javac.exe, java.exe, and jar.exe one at a time using Configure>Preferences>Tools --> Add --> Program...
I found these files in the ...jdk\bin file which for me happened to be saved in C:\Sun\AppServer\jdk\bin. You may have saved them in a similar place or in Program Files. Anyways, I added each tool and then, by gently left clicking once on the tool name in the Tools Menu, was able to rename them to Compile JAVA, Run JAVA, and Create JAR. You can just leave them as javac.exe, java.exe, etc. or name them whatever you choose.
So far so good? Now's where the trouble began for me. To the best of my knowledge, JDK 5.0 does not add a CLASSPATH variable to User or System environment variables (so don't worry about all the CLASSPATH variable stuff in these blogs) but it does add a PATH variable, and this is a good thing (CLASSPATH bad, PATH good). Simply go to Control Panel>System>Advanced>Environment Variables and verify that the string C:\Sun\AppServer\jdk\bin (or wherever your javac.exe, java.exe, etc. are found) is present among your PATH variables.
At this point, you should be able to compile HelloWorld.java in TextPad, but you probably cannot run JAVA programs. The reason for this is that if you added java.exe through the Add --> Program... method I mentioned above, for some reason the File parameter is incorrect. Hear me out.
The command line for compiling HelloWorld.java in DOS is:
javac HelloWorld.java
You may verify that in your Tools>Compile JAVA
Parameter: $File
Initial Directory: $FileDir
So far so good. And the command line for running HelloWorld after compiling it is:
java HelloWorld
however, if your Tools>Run JAVA parameters say
Parameter: $File
Initial Directory $FileDir
then you are essentially running the command line:
java HelloWorld.java
which is incorrect. To resolve this problem, simply replace Tools>Run JAVA
Parameter: $File
with
Parameter: $BaseName
which will change your command line from the incorrect
java HelloWorld.java
to the correct
java HelloWorld
When I did this, both my Compile JAVA and Run JAVA tools ran without a hitch. It took me a while to figure this out, so I hope can be of use to somebody else.
By the way, I haven't tried appleviewer.exe or jar.exe, but I imagine there might be similar issues with matching the correct command line and the Parameter variable in TextPad.
I recently downloaded Sun's AppServer bundle including SDK 5.0 to C:\Sun\AppServer. I then downloaded TextPad.
Unfortunately for me, Configure>Preferences>Tools --> Add did not automatically show "JAVA SDK Commands", so I added javac.exe, java.exe, and jar.exe one at a time using Configure>Preferences>Tools --> Add --> Program...
I found these files in the ...jdk\bin file which for me happened to be saved in C:\Sun\AppServer\jdk\bin. You may have saved them in a similar place or in Program Files. Anyways, I added each tool and then, by gently left clicking once on the tool name in the Tools Menu, was able to rename them to Compile JAVA, Run JAVA, and Create JAR. You can just leave them as javac.exe, java.exe, etc. or name them whatever you choose.
So far so good? Now's where the trouble began for me. To the best of my knowledge, JDK 5.0 does not add a CLASSPATH variable to User or System environment variables (so don't worry about all the CLASSPATH variable stuff in these blogs) but it does add a PATH variable, and this is a good thing (CLASSPATH bad, PATH good). Simply go to Control Panel>System>Advanced>Environment Variables and verify that the string C:\Sun\AppServer\jdk\bin (or wherever your javac.exe, java.exe, etc. are found) is present among your PATH variables.
At this point, you should be able to compile HelloWorld.java in TextPad, but you probably cannot run JAVA programs. The reason for this is that if you added java.exe through the Add --> Program... method I mentioned above, for some reason the File parameter is incorrect. Hear me out.
The command line for compiling HelloWorld.java in DOS is:
javac HelloWorld.java
You may verify that in your Tools>Compile JAVA
Parameter: $File
Initial Directory: $FileDir
So far so good. And the command line for running HelloWorld after compiling it is:
java HelloWorld
however, if your Tools>Run JAVA parameters say
Parameter: $File
Initial Directory $FileDir
then you are essentially running the command line:
java HelloWorld.java
which is incorrect. To resolve this problem, simply replace Tools>Run JAVA
Parameter: $File
with
Parameter: $BaseName
which will change your command line from the incorrect
java HelloWorld.java
to the correct
java HelloWorld
When I did this, both my Compile JAVA and Run JAVA tools ran without a hitch. It took me a while to figure this out, so I hope can be of use to somebody else.
By the way, I haven't tried appleviewer.exe or jar.exe, but I imagine there might be similar issues with matching the correct command line and the Parameter variable in TextPad.
Re: Got it to work!!!
8) PERFECT Solution. Thanks for the post.dhopp5 wrote:
Thank you for your posts. I got it to work. One of the most frustrating things I find in java is typos....
To set the class path on 2000 and XP right click my computer; goto properties; click on advanced; click on Environmental variables; add a new variable (on the bottom half of the window)
CLASSPATH=.;C:\j2sdk1.4.2_09\bin
The j2sdk1.1.2_09 may be different depending on you current version of Java.
Re: Need help with J2EE SDK 5.0 & TextPad on Windows XP?
MY GOD! I OWE YOU MY LIFE! school ended and i wanted to continue my java learning at home, long story short i got this error and lost all hope after reading those ridiculously confusing guides about the classpath whatever. i am a very unlucky person, these types of things always happen to me. but today was my lucky day, i read your post and fixed my problem! i dont even know how to express my gratitude for this thank youseouljake wrote: The command line for compiling HelloWorld.java in DOS is:
javac HelloWorld.java
You may verify that in your Tools>Compile JAVA
Parameter: $File
Initial Directory: $FileDir
So far so good. And the command line for running HelloWorld after compiling it is:
java HelloWorld
however, if your Tools>Run JAVA parameters say
Parameter: $File
Initial Directory $FileDir
then you are essentially running the command line:
java HelloWorld.java
which is incorrect. To resolve this problem, simply replace Tools>Run JAVA
Parameter: $File
with
Parameter: $BaseName
which will change your command line from the incorrect
java HelloWorld.java
to the correct
java HelloWorld
When I did this, both my Compile JAVA and Run JAVA tools ran without a hitch. It took me a while to figure this out, so I hope can be of use to somebody else.
By the way, I haven't tried appleviewer.exe or jar.exe, but I imagine there might be similar issues with matching the correct command line and the Parameter variable in TextPad.
yyyyy
i got the same problems
Classpath : C:\Program Files\Java\jre1.5.0_07\lib\ext\QTJava.zip
path : %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.5.0_02\bin
TextPad :
RunJava Apllication :
Parameter : $basename
Initital folder : $filedir
help me,please...
Classpath : C:\Program Files\Java\jre1.5.0_07\lib\ext\QTJava.zip
path : %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.5.0_02\bin
TextPad :
RunJava Apllication :
Parameter : $basename
Initital folder : $filedir
help me,please...