Please note that ItDoesntWorkIsUseless(⇐click). You need to TellTheDetails(⇐click). For instance, paste in the exact, complete error message, along with the code that caused it, and indicate clearly which line was the culprit.
Also note that precision is very important. A "lang error" is not a standard term. Perhaps you meant java.lang.Error?
Exception in thread "main" java.lang.NoClassDefFoundError: GreetingsUniverse/class
Caused by: java.lang.ClassNotFoundException: GreetingsUniverse.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown source)
Could not find the main class: GreetingsUniverse.class. Program will exit.
That tells us that you did something like
java -cp . GreetingsUniverse.class when you should have done something like
java -cp . GreetingsUniverse
Java takes the class name, and then adds ".class" and searches for a file with that name that defines the class in question. And dots in the class name are used to specific a package, which end up corresponding to directories when searching for the .class file. So in short: Just provide the class name, without the ".class" extension.
Eric Rounding wrote:All three of the above were true.
I amended enironment variables:
No, it was something else. There is no way these changes would affect the above. For one thing, if you use -cp on the command line, it supersedes the CLASSPATH env var. For another thing PATH has nothing to do with finding classes, only with finding executables, and since you were able to get that error, it definitely found and executed the java VM executable.
Also, you should generally not set the CLASSPATH env var at all, and you should definitely not set it to include anything in your Java installation directory tree.
You must have changed something else as well. I'm glad it works now, but it would have been nice to figure out what you were doing wrong so that you won't have to guess next time it happens.