| Author |
How to compile and Run
|
Varuna Seneviratna
Ranch Hand
Joined: Jan 15, 2007
Posts: 164
|
|
I tried to compile and run this program <program> public class HelloWorld{ public static void main(String[]args){ System.out.println("Hello!"); } } </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) What can be the reason
|
Varuna Seneviratna
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
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.
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
Yes, you may please try out the options suggested by CR. Varuna, could you please make use of the "Code" Tags when posting the java code so that it gives a good and clear look and makes the code uncluttered?
|
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
|
 |
 |
|
|
subject: How to compile and Run
|
|
|