This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
} </program> This compiles, But when I try to run the program from the command prompt I get the following errors. Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld (U nsupported major.minor version 50.0) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) 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) at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Try entering "javac -version" and "java -version" and see what you get.
That sort of error usually means you are compiling the code with a newer version of the compiler than of the JVM. In which case you might get 1.5.0 for javac and 1.4.2 for java. The API details here are a bit laconic.
You can sort out the javac with a command to compile with compatibility to older versions of the JVM, but that will restrict you to using older functionality. Look here (Windows) or here (version 1.5 for Solaris) for details of the -source and -target options.
If it were me, I'd try going here and downloading a new JDK.