Java.lang.UnsupportedClassVersionError

When I ran the java program, I got this error. Could you suggest why we get this error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: GenerateInvoice (Unsupported major.minor version 49.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) 
+50
java unsupported-class-version
Oct 07
source share
4 answers

This class was compiled with the JDK later than the one used for execution.

The easiest way is to install a newer JRE on the computer where you are running the program. If you think you have installed the latest version, check the JAVA_HOME and PATH environment variables.

Version 49 is java 1.5. This means that the class was compiled (or for) by the JDK, which is still old. You were probably trying to execute a class with JDK 1.4. You really should use one more recent one (1.6 or 1.7, see the history of the Java version ).

+86
Oct 07
source share

Another option is to remove all classes and rebuild. Having an assembly file is ideal for managing the entire process, such as collection, packaging, and deployment. You can also specify source / target versions

+4
Oct 07 '12 at 17:36
source share

Most likely, the code was compiled with a later JDK (without using cross-compilation options ) and runs on an earlier JRE. Although updating the JRE is one solution, it would be better to use cross-compilation options to ensure that the code will run on any JRE intended as the minimum version for the application.

+1
Oct 07 '12 at 16:30
source share

It was the new Linux Mint xfce machine

I struggled with this for about a week. I am trying to learn Java on the Netbeans IDE, and therefore, naturally, I get a combo file directly from Oracle. What is the JDK and Netbeans IDE package together in the tar file located here.

located http://www.oracle.com/technetwork/java/javase/downloads/index.html JDK 8u25 file name with NetBeans 8.0.1

after installing them (or so I thought), I would make / compile a simple program, such as "hello world", and this will spit out the jar file that you can run in the terminal. Keep in mind that the program ran in the Netbeans IDE.

I would end up with this error: java.lang.UnsupportedClassVersionError:

Although I was running the file from the oracle website, I still had an old version of the Java runtime that was not compatible with the jar file that was compiled with the new version of java.

After you come across things that were mostly above my head, from installing Paths to editing .bashrc without fixing it.

I came across a solution that was easy enough for me. I came across the fact that it automatically installs java and configures it on your system, and it works with the latest 1.8. *

One of the steps is to add PPA, at first there wasnโ€™t any certainty about it, but it seems to be fine, since it worked for me.




sudo add-apt-repository ppa: webupd8team / java

Sudo apt-get update

sudo apt-get install oracle-java8-installer




domenic @ domenic-AO532h ~ $ java -version java version "1.8.0_25" Java (TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot (TM) Server VM (build 25.25-b02, mixed mode)

I think it also configures java browser.

Hope this helps others.

-one
Nov 01 '14 at 4:14
source share



All Articles