Problem in running my first sample program
I made this simple program from the book Teach Yourself Java 2:
publicclass HelloUser{
publicstaticvoid main (String[] arguments){
String username = System.getProperty("user.name");
System.out.println("Hello, " + username);
}
}
Now my problem is when I use the command line to compile my program, it displays no error. But when I run it this message appears:
Exception in thread"main" java.lang.NoClassDefFoundError: HelloUser
I have set the ClassPath variable and the Path as well. Both the .java and .class files are in the same folder. But when I used JCreator, I was able to view the output in the output window.
Anyone knows why I can't see the results in the command prompt window? It really puzzles me.
Ok, run again dir, javac, dir and java commands and send complete copy of output using copy of terminal, not few words by manual retyping.
It should be something like:
C:\Work\o\Hello>dir
Volume in drive C is XX
Volume Serial Number is XXXX-XXXX
Directory of C:\Work\o\Hello
26.04.2007 17:52<DIR> .
26.04.2007 17:52<DIR> ..
26.04.2007 17:50181 HelloUser.java
1 File(s)181 bytes
2 Dir(s) 12 005 871 616 bytes free
C:\Work\o\Hello>javac HelloUser.java
C:\Work\o\Hello>dir
Volume in drive C is XX
Volume Serial Number is XXXX-XXXX
Directory of C:\Work\o\Hello
26.04.2007 17:52<DIR> .
26.04.2007 17:52<DIR> ..
26.04.2007 17:52671 HelloUser.class
26.04.2007 17:50181 HelloUser.java
2 File(s)852 bytes
2 Dir(s) 12 005 867 520 bytes free
C:\Work\o\Hello>java -cp . HelloUser
Hello, XXX
C:\Work\o\Hello>