2 Ways To Solve Unsupported Major.Minor Version 51.0 Fault Inwards Java

Advertisement

Masukkan script iklan 970x90px

2 Ways To Solve Unsupported Major.Minor Version 51.0 Fault Inwards Java

Sabtu, 26 Desember 2020

Unsupported major.minor version 51.0 fault comes when y'all run a degree file created using Java 1.7 (major version 51.0) into a lower JRE version e.g. JRE 6, v or 4. There are ii ways to solve this problem, starting fourth dimension brand certain y'all run your Java computer programme inwards same or higher version of JRE, on which it has compiled, as well as minute role cross-compilation pick to produce a degree file compatible to a lower JRE. You tin role javac -target pick to produce a degree file for all JRE up-to-the JDK version y'all are using for compilation. For example, if y'all are compiling your Java source file into JDK 1.7 as well as thus y'all tin produce degree files to run on JDK 1.1, 1.2, 1.3, 1.4 , 1.5 as well as 1.6 version, but y'all cannot produce degree files compatible amongst Java 1.8. When y'all compile a Java source file, it creates a class file as well as add together the degree file version into it. In social club to run that degree file, your JRE must empathise that version. When JRE or JVM which is running the degree doesn't able to empathise the degree file version they throw java.lang.UnsupportedClassVersionError: XXX : Unsupported major.minor version 51.0 error, where XXX is the parent of your degree which has an incompatible version.



Solution 1 - Upgrade JRE

Simplest solution to ready Unsupported major.minor version 51.0 fault changes your Java virtual machine. Upgrade JRE to acquire a version same or higher than the version y'all convey used for compiling your project. Once y'all got that, only run your computer programme again. It should function fine this time. Since java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0 clearly says that this file needs, at least, Java seven or higher to run. You require to install 32-bit or 64-bit JDK 1.7 or JRE 1.7 version depending upon whether y'all are running on 32-bit or 64-bit OS e.g. If y'all are running on Windows seven or Windows 8 as well as thus install a 64-bit version of JDK. You would also endure fine if y'all are running on Java 8, but don't run the computer programme on Java vi or lower version.



Solution 2 - Use javac -target option

As y'all know at in 1 trial that source sweat of any java.lang.UnsupportedClassVersionError: Unsupported major.the tyke version is incompatible JRE version at run-time, but changing JRE is non the exclusively solution y'all have, y'all tin fifty-fifty compile your degree file for lower JRE version. In social club to adjust this solution, y'all require to re-compile your project.

If recompilation is an pick as well as thus brand certain y'all add together -target pick to javac amongst corresponding Java version y'all are looking every bit target runtime. For example, if y'all are generating degree file to run on Java 6, y'all tin overstep the next declaration to javac command :

javac -target 1.6 *.java

*.java is to compile all Java files as well as target 1.6 agency the degree file volition endure compatible amongst Java SE vi JVM. If y'all desire to compile a degree file for Java 5, only role -target 1.5 option. See Core Java Volume 1 tenth Edition past times Cay S. Horstmann for to a greater extent than special on Java compiler.

 fault comes when y'all run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java



How to ready Unsupported major.minor version 51.0 inwards Eclipse

If y'all are getting Unsupported major.minor version 51.0 error piece running your projection inwards Eclipse, as well as thus y'all require to alter compiler pick for your projection inwards Eclipse. This truly happens when y'all convey a projection specific compiler version setting but running on Eclipse's default JRE. If y'all after changed Eclipse default JRE from JDK 1.7 to JDK 1.6, y'all volition come across next fault :

java.lang.UnsupportedClassVersionError: dto/ReverseArrayInPlace : 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) Exception inwards thread "main" 


You tin come across follow next steps to solve Unsupported major.minor version 51.0 fault inwards Eclipse IDE:

1. Select project, correct click, select properties

2. Select Java Compiler option, every bit shown below, y'all volition come across that JDK 1.7 was selected past times default

 fault comes when y'all run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java


3. Check the checkbox "Enable projection specific settings"

4. Choose the Compiler compliance bird y'all want, every bit shown below :

 fault comes when y'all run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java


Choose 1.6 if y'all desire to run your computer programme on Java vi JVM, direct 1.7 if y'all desire to execute your Java computer programme amongst JRE 1.7 etc.

Alternatively, y'all tin also alter the JRE version inwards Run Configuration past times doing next steps :

1. Click on Run Menu as well as and thus direct Run Configurations every bit shown below

2. Choose your Java Application from left side listing of Java application which has run configuration

 fault comes when y'all run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java



3. Select the JRE tab, if y'all are already getting this fault as well as thus y'all would come across the blood-red cross on the tab, alert y'all almost a mismatch JRE version.

4. Just select the correct JRE version to run your computer programme i.e. if y'all are compiling using JDK seven as well as thus direct Java seven here.
 fault comes when y'all run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java


Once y'all brand this change, y'all tin only run your Java application as well as it should run fine, without whatsoever sign of java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0 error.

That's all almost how to solve Unsupported major.minor version 51.0 fault inwards Java and, inwards particular, Eclipse IDE. Once y'all know the source sweat it becomes slow to solve the problem, it's ever a mismatch betwixt Java version at compile as well as run-time.  You tin also acquire unsupported major.minor version 51.0 error from your produce tool e.g. Maven as well as ANT. Since they internally role javac compiler to compile the file, y'all require to customize corresponding delineate e.g. inwards ANT, in that place is a javac delineate to compile source file, only render target parameter to it to solve this problem.

Further Learning
Understanding the Java Virtual Machine: Class Loading as well as Reflection
Java Fundamentals, Part 1 as well as 2
Core Java for the Impatient - Covers Java SE 8

Related debugging tutorials

If y'all similar this tutorial as well as wants to acquire to a greater extent than almost troubleshooting errors as well as exception inwards Java, only cheque around of my before tutorials as well as debugging guide. You volition acquire source sweat of many mutual Java problems as well as tips to solve them :
  • How to ready Unsupported major.minor version 52.0 fault inwards Java [solution]
  • Failed to connect to Queue using WebSphere MQ Series fault [solution]
  • How to fix java.lang.classnotfoundexception sun.jdbc.odbc.jdbcodbcdriver erorr [solution]
  • Solution of JDBC fault java.lang.ClassNotFoundException: org.postgresql.Drive [solution]
  • How to bargain with java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver? [solution]
  • Root sweat of  java.lang.ClassNotFoundException: com.mysql.jdbc.Drive fault inwards Java? [solution]
  • Cause as well as solution of java.sql.SQLException: No suitable driver : sqljdbc4.jar [solution]
  • Root sweat java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver inwards Java? [analysis]