java problem

Status
Not open for further replies.

aphextwin

Beta member
Messages
2
hello,

i was writing a java program and was wondering what i am doing wrong...

i compiled it, and when i type "java Test" it comes up with this error....

Exception in thread "main" java.lang.NoClassDefFoundError: Test

i dont see any problems with my code because it compiles... im using jdk1.5.0_05 i really dont know....
Code:
public class Test
{
	public static void main(String[] args) 
	{
		System.out.println("Hello World!");
	}
}
incase you want the code, simple hello world one
please help
 
prolly missing some include/import of standard classes. you prolly need the class for input & output.


it compiles cus the syntax is correct
 
I think, the problem will be due to missing imports like
import java.io.*;

The problem is very funny. U better reinstall the jdk as some files would have been corrupted i suppose...
 
Make sure that the .class is being created properly in the directory. If it's in there, try typing this at your command prompt:

java -classpath . Test

The reason it came back with that error is because your PATH is probably set to something other than the directory you are in. So when you tried to run it, it was only looking in the PATHs directory, not your current directory. In this case, you have to specify where the main class file is, and its name. Also, I am assuming you named your class Test.class.
 
Status
Not open for further replies.
Back
Top Bottom