0

I am getting this error

Exception in thread "main" java.lang.UnsupportedClassVersionError: RunAll : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        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$000(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)
  Could not find the main class: RunAll.  Program will exit.

I copied the folder from my collegue , and set the class path (the required jars application related) And when i run that , i am getting the above Erorr .

I don't why i am getting this error , because we have same java versions .

java version "1.6.0_27" Java(TM) SE Runtime Environment (build 1.6.0_27-b07) Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)

1
  • are you sure it's compiled with jdk 6? Commented Nov 24, 2011 at 13:37

5 Answers 5

4

I suspect your colleague is using Java 7 - the Java 7 compiler emits bytecode using version 51.0 unless told not to.

Either rebuild the code yourself, or ask him to rebuild with an appropriate -target option.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks , java 6 version is used on either sides , please tell me what does " rebuild the code yourself" means ??
@Revathi: Well something is using JDK 7 to build RunAll.class. By "rebuild the code yourself" I mean "get hold of the source code for RunAll, and run the compiler yourself".
1

The generic answer is: you can't run classes compiled with a higher version on a lower version JVM.

In your case, the classes are compiled with Java 7, and you are trying to run them with Java 6.

Comments

1

Version 51 class are produced by Java 1.7 so you and your colleague don't have the same Java versions. Whoever is compiling the code is using Java 1.7.

So your options are:

  • Upgrade your enviroment to 1.7
  • Get your colleage to upgrade his environment
  • Compile the .java files to .class files yourself

Comments

0

the class you are attempting to run was compiled using J2SE 7. Your colleague is clearly not compiling with the JVM he thinks he is compiling with.

Comments

0

I was searching for that error code, and came across this thread, I then discovered, I was running a different Java VM then my JDK's. I updated my enviromental varaibles and launched my application on the VM provided with my JDK, and it solved the issue.

Thanks to this thread it gave me hint what to check.

I was basically running Apache TomCat on a diffrent VM then the one my JDK was compiling for, after I update my setup, and restarted TomCAT with the correct Java paths my issue was resolved.

To answer your question, make sure your JDK, and Java VM match.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.