General discussion

Locked

java.lang.NoClassDefFoundError

By gramlow ·
I have newly installed Java 1.3.1 and Textpad 4. I am trying to run the following program:
public class Hello
{ public static void main(String args[])
{ System.out.println("Hello, World!");
}
}
It works on other computers, but not on my home computer. It compiles fine, but when I run it, I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
This same error comes up for every program I try to run.
I am getting suggestions to change the classpath in DOS, but that does not work, and I shouldn't have to do this for every program I run...any suggestions?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

java.lang.NoClassDefFoundError

by Kinjal In reply to java.lang.NoClassDefFound ...

try saying
set classpath=.

Collapse -

java.lang.NoClassDefFoundError

by gramlow In reply to java.lang.NoClassDefFound ...

This does not take care of the problem within Textpad. For some reason, Textpad is not automatically seeing the classpath, which it should be. Typing in Set classpath works in DOS, but I shouldn't have to do this when I am using textpad to compileand run Java programs

Collapse -

java.lang.NoClassDefFoundError

by Kinjal In reply to java.lang.NoClassDefFound ...

thats was a variable I was not aware of..

can you change the command line used to invoke the javac and java from within textpad? you could change the command line to include the -classpath like this:

java -classpath=. xyz

under windows youcan TRY

java -classpath=%classpath%;. xyz
if this does not work, you can put the entire classpath there:

java -classpath=c:\libs\servlet.jar;c:\libs\jdbc.jar xyz

if you face any problems with that try putting the actual classpath within double quotes, like this:

java -classpath="jar1.jar;jar2.jar" xyz

enjoy

Collapse -

java.lang.NoClassDefFoundError

by gramlow In reply to java.lang.NoClassDefFound ...

Just wanted to give an update. I was able to get some assistance from one of the professors at school. He had me do the following:
1. Open DOS Window
2. Type the command Set (this should show that you have a classpath set to some odd path thathas nothing to do with Java; if so,
3. Type Edit Autoexec.bat
4. When this window comes up, arrow down to the set classpath line and add the following characters to the line ;. (semicolon period). Save changes and exit.

This took care of theproblem!

Collapse -

java.lang.NoClassDefFoundError

by gramlow In reply to java.lang.NoClassDefFound ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums