Jesper de Jong wrote:When you run the program, you must enter the command:
Note: Not java Test.class. You're not specifying the filename there, but the name of the class.
Thanks, had already tried that. I'll make sure I do not type class in the future. But without .class I still get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: Test
Caused by: java.lang.ClassNotFoundException: Test
at java.security.AccessController.doPrivileged(Native Method)
Jeremy James Brown
Joined: Mar 24, 2011
I booted up my Ubuntu laptop and the code compiled on the win box runs properly. I must have a problem with my windows java.
javac compiles on the win box. java returns the Usage: java text.
In that case, it looks like your Windows machine has a system/user variable set for "classpath" that does not include a dot for the current directory. Try changing the current directory to the location of your compiled Test.class file, then provide a command-line classpath (cp) of the current directory (.) by typing...
java -cp . Test
If that works, then it confirms the classpath theory, and you should either remove the system/user classpath entirely (if there's nothing else in that path you need), or at least add a dot to to list of paths.
Edit: A lot of people make the mistake of creating a classpath variable pointing to the jdk bin directory. This directory should be added to your "class" variable, but you do not need a "classpath" pointing to that location.