Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java command error

 
Jude Fawly
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I wrote a program and it compiles correctly from command line with (javac), but when I use (java) to run the application, I get the following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: art (Unsupported major.minor version 50.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)


----
Can somebody help?
Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're compiling with the javac from JDK 6, but running with an older version of Java. This often happens because Java installers will sometimes, but not always, put a copy of java.exe into c:\WINDOWS\ (or some equivalent) to support the Java Plugin. Either find that extra java.exe and replace it, or replace it with java.exe from JDK 6, or change your PATH environment variable to put the Java 6 bin directory first, or use an explicit path to invoke java.exe from that directory... etc.
 
Jude Fawly
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,

I went with one of the options you provided which is to change the path in the environment variables to take java.exe from the java bin directory as the first option. It is working now.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic