I have absolutely no idea what has gone wrong here. One day I have a perfectly working system using rosjava, and then the next morning I am getting this error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/ros/RosRun : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: org.ros.RosRun. Program will exit.
I haven't changed any code, updated any files, nothing. This just happened. Does anyone have any idea why?
Things I have tried: After doing research on errors similar to this, I found out that it occurs when java versions do not match. 51 is Java 1.7. So I checked out my own java version with:
java -version
and got:
java version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (6b33-1.13.5-1ubuntu0.12.04)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
So I am running java 1.6. Makes sense, the error is telling me RosRun is 1.7. Let me check.
$ file RosRun.class
RosRun.class: compiled Java class data, version 50.0 (Java 1.6)
Well thats not the case. That means my code must be compiling in 1.7. Let me check:
$ file project/build/classes/main/com/github/hsmrs_gui/project/GuiNode.class
project/build/classes/main/com/github/hsmrs_gui/project/GuiNode.class: compiled Java class data, version 50.0 (Java 1.6)
I'm at a loss. Can anyone help?
I ran $sudo apt-get upgrade which turned the output of $java -version into:
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)
and then reran my code. It works now. I still have no idea why this broke in the first place though.
Related
I am trying to use Nextflow to run a pipeline for RNA sequence; however I keep having issues with Java.
Currently the error I am receiving is:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/eclipse/jgit/api/errors/GitAPIException has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
I have the following Java Versions, but I will be honest, I tried many many routes to get to this newest version of java (the old one was:
openjdk version "1.8.0_332"
OpenJDK Runtime Environment (Zulu 8.62.0.19-CA-linux64) (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (Zulu 8.62.0.19-CA-linux64) (build 25.332-b09, mixed mode))
Now these are the updated versions:
$ javac -version
javac 17.0.5
$ java -version
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)
Please help!
A good idea in this situation would be to uninstall and install a newer version of JDK.
You may have missed the note that usually accompanies the error above:
$ nextflow -h
NOTE: Nextflow is not tested with Java 1.8.0_332 -- It's recommended the use of version 11 up to 18
Just make sure you have Java 11 (or later, up to 18) installed.
I try to compile https://github.com/CuriousNikhil/k5-compose in IntelliJ, I got the below error
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61326:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/tools.jar:/Users/elisha.lye/Development/experiment/k5-compose/build/classes/kotlin/main:/Users/elisha.lye/Development/experiment/k5-compose/k5-compose/build/classes/kotlin/main:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.21/6b3de2a43405a65502728047db37a98a0c7e72f0/kotlin-stdlib-jdk8-1.5.21.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.21/f059658740a4b3a3461aba9681457615332bae1c/kotlin-stdlib-jdk7-1.5.21.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.21/2f537cad7e9eeb9da73738c8812e1e4cf9b62e4e/kotlin-stdlib-1.5.21.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.desktop/desktop-jvm/1.0.0-alpha3/7d2ec16f4e057de47d41ffc5c8416f9f85aeab3e/desktop-jvm-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.21/cc8bf3586fd2ebcf234058b9440bb406e62dfacb/kotlin-stdlib-common-1.5.21.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.material/material-desktop/1.0.0-alpha3/60d4a46d2ee31e82ab61342887203b23aee0ba83/material-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.foundation/foundation-desktop/1.0.0-alpha3/29c590b69d13ec16352497848d1bf05da1de062e/foundation-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-desktop/1.0.0-alpha3/7f33f2592490b6d23494c0842d6f15ac592f9bb7/ui-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-tooling-preview-desktop/1.0.0-alpha3/4676c56ea7defd68facfab054079ac1e76aba57f/ui-tooling-preview-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.runtime/runtime-desktop/1.0.0-alpha3/481c6e0d45e192d4f02f993e049262e0668f6018/runtime-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-swing/1.5.0/f9702179f0e36a0541ffe77a7a62596c4fc6ad83/kotlinx-coroutines-swing-1.5.0.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.2.0/57136ff68ee784c6e19db34ed4a175338fadfde1/annotation-1.2.0.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.material/material-ripple-desktop/1.0.0-alpha3/ffc54fa1f9c6e164d6ccdd53f7411bd80ccbce6c/material-ripple-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.material/material-icons-core-desktop/1.0.0-alpha3/3e869bc14a82c27647e3719579d6acb517d2fc2a/material-icons-core-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.animation/animation-core-desktop/1.0.0-alpha3/ec648418e6980b80f376f2b0455d5e2ba74f0445/animation-core-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-text-desktop/1.0.0-alpha3/c1706e1e249c65fe08a672f3ab8f442ee864cf59/ui-text-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.animation/animation-desktop/1.0.0-alpha3/eeff15e8d42d2fab8e6fb4eb0356ae397070aa49/animation-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.runtime/runtime-saveable-desktop/1.0.0-alpha3/1b7a4801b28b5541d87cd9ae560571a77cc94dd/runtime-saveable-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-graphics-desktop/1.0.0-alpha3/f3b1bfc01b7316e6d5af522b1025fe09f7fff137/ui-graphics-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-unit-desktop/1.0.0-alpha3/5cefe80c330e154436abdb12825a828229ed950f/ui-unit-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-geometry-desktop/1.0.0-alpha3/261a169b4e2816397d8c4e22e63a2d590f99210a/ui-geometry-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm/1.5.0/d8cebccdcddd029022aa8646a5a953ff88b13ac8/kotlinx-coroutines-core-jvm-1.5.0.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.skiko/skiko-jvm/0.3.9/8b3108a3fb80baa30163d20d8176f108d895b44f/skiko-jvm-0.3.9.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.foundation/foundation-layout-desktop/1.0.0-alpha3/878f19bd721b99f677e959d96595573f8198eb1c/foundation-layout-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.skiko/skiko-jvm-runtime-macos-x64/0.3.9/7dd5c3ab33897ea23d4e46251a7d04515755d0dd/skiko-jvm-runtime-macos-x64-0.3.9.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-util-desktop/1.0.0-alpha3/6de31edde97babd7339e67bb1b82ebff1a805e9c/ui-util-desktop-1.0.0-alpha3.jar MainKt
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: MainKt has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
This is clearly because it needs Java 11, and it got compiled in Java 8.
However, when I check all places I see, they are all set to Java 11. The below is what I have checked
1. In the Terminal environment
java -version
openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)
elisha.lye#C02FF0VFQ05N k5-compose %
2. In the Gradle setting
3. In the Java Compiler
4. In the JRE Setting
Where do I miss setting my Java Run Time?
1 - Is for your OS and terminal, nothing common with the project
2 - Is the JDK for running Gradle. For Gradle daemon itself, not for the project
3 - Is the project's bytecode version which could be overwritten in module.
4 - Is the Runtime environment for the IDE itself.
So, you need to edit Project Structure > Project setting > Project > Language level See https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk
[Edit Configurations...] or [Modify Run Configuration...] menu to open the "Run/Debug Configurations" dialog.
Select the runtime version from the [JRE:] drop-down menu.
Older posts I see associated with UnsupportedClassVersionError have the message
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
But when I compile a class with JDK 1.8 and run it with JDK 1.7 I get
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld : Unsupported major.minor version 52.0
Are these messages caused by the same thing but just have changed over time?
Why can I find neither message in the source code for rt.jar?
Update
Here's my simple class:
public class HelloWorld{
public static void main (String[] args) {
System.out.println("Hello, World!");
}
}
Compiling and running with the same version:
$ java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
$ javac HelloWorld.java
$ file HelloWorld.class
HelloWorld.class: compiled Java class data, version 52.0
$ java HelloWorld
Hello, World!
And then running with a lower version than that which I used to compile the class:
$ $JAVA7_HOME/bin/java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
$ $JAVA7_HOME/bin/java HelloWorld
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
All of this was expected, I was just wondering if the messages were equivalent because I have someone reporting 'Bad version number' and then just got curious as to why I couldn't see the message in the source code. #eugenioy's answer is what I was looking for.
1) Messages are equivalent and probably either changed over time or are thrown in different parts of the code with different values.
You can see here that they should be treated equivalently:
https://blogs.oracle.com/sundararajan/entry/java_class_ic_errors
2) I could not find the messages in the sources for the JDK (rt.jar). That probably means that the exception is thrown in the HotSpot JVM, and not by a class present in the JDK.
Actually, if you look at this interface in the JDK: java.lang.instrument.Instrumentation, you'll see that there are a couple of methods that throw UnsupportedClassVersionError.
But I see no implementations in the source for the JDK.
To find the place where the exceptions are thrown you probably need to look at the source code for the HotSpot JVM:
https://blogs.oracle.com/sundararajan/entry/so_you_want_to_read
I'm fully aware that this question has already been asked in a way in this thread:
Cassandra:UnsupportedClassVersionError
However, the answer/s given there, which I accept, don't solve my problem as I do have a current version of Java as detailed below:
D:\Development\Cassandra\apache-cassandra-2.0.6>java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)
Knowing this, I still receive the error when starting Cassandra:
D:\Development\Cassandra\apache-cassandra-2.0.6>bin\cassandra -f
Starting Cassandra Server
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/cassandra/service/CassandraDaemon : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.cassandra.service.CassandraDaemon. Program will exit.
I'm running on a Windows XP machine using the command prompt (not Cygwin) to start Cassandra and I'm able to start older versions of Cassandra without any issue (apache-cassandra-1.1.4). Am I doing something incorrect with the later version of Cassandra or have I missed something somewhere in my configuration that is blindingly obvious?
The only plausible explanation for that exception is that a Java 6 (or earlier) JVM is being use to run code that was compiled for the Java 7 target platform.
This contradicts what you believe to be happening. Nevertheless, it is the only plausible explanation.
I suggest that you make a copy of the cassandra wrapper script (in the same directory), and hack it to:
add set -x at the start to see what commands are actually being run by the script.
add echo $PATH, echo $JAVA_HOME and so on to see what the key environment variables are in the script's environment.
add a line to run java -version using the exact same command path that is being use to run the JVM for real.
This should reveal which of your beliefs / assumptions about what is happening are incorrect.
I did try with uninstalling java 1.7 and installing the latest java 8 got solved my issue.
I was doing my homework in eclipse and it reported no errors, not even warnings. When I tried to compile it from terminal I got following error. It runs and compiles just fine with eclipse. I take it it has something to do with java version? Anyway to fix it or try to bypass it?
vedran#vedran-debian:~/java/oop/Aufgabe6$ java Test
Exception in thread "main" java.lang.UnsupportedClassVersionError: Test : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Test. Program will exit.
Java version:
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-1)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
EDIT:
Thank you all for your explanations. It seems to be a java6/7 issue. I just compiled it with 1.6 and it worked like charm.
The Test.class file has been compiled in Java 7 (major/minor version 51.0), so it's incompatible with the Java 6 (major/minor version 50.0) runtime. Either compile the .java file in Java 6 (or earlier), or run the .class in a Java 7 runtime.
Maybe your Compiler in eclipse is different? Preferences -> Compiler: Compiler level. Maybe Java 7?
If you are under Linux, you can have a look for all your installed runtime environments: update-alternatives --config java. Here you can choose the correct one. Here you should be able to find the OpenJDK 7.
51.0 indicates Java version 7, so the class file you're trying to run was compiled with a version 7 compiler. If you need to run the code with a version 6 JVM you should instruct the compiler to emit version 6 compatible byte code.
javac -version 6 ...
That command line argument will force a higher version compiler to restrict its output to bytecode that's compatible with a version 6 runtime environment.
In Eclipse, go to Window-->Preferences-->Java-->Compiler and you will see a field labeled "Compiler compliance level". Set it to 1.6, and recompile in Eclipse.
There is a Java version mismatch between Eclipse and your command-line javac. Specifically, your javac seems to be using 64-bit 1.6. Eclipse apparently is using 1.7.
Is it possible you've compiled your Test program Java 7 and are now attempting to run it against Java 6 in the terminal? I would try recompiling in the terminal (ie. Java 6) if that's the case and then attempt to re-run the program.
If solutions above are all set , if u still have the same issue and
if your using MAVEN then check in the pom.xml. JAVA ASSIST JAR should point 16.1-GA if your using jdk 1.6 else corresponding version should be added for the jdk that you are pointing to.(eg : 3.17.1 for jdk 7).For jdk 6 add the dependency with the following details
groupId : org.javassist
artifactId: javassist
version : 3.16.1-GA