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

Unsupported major.minor version 51.0 fault comes when you lot run a degree file created using Java 1.7 (major version 51.0) into a lower JRE version e.g. JRE 6, five or 4. There are 2 ways to solve this problem, kickoff brand certain you lot run your Java plan inward 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 you lot are using for compilation. For example, if you lot are compiling your Java source file into JDK 1.7 thus you lot 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 you lot cannot produce degree files compatible alongside Java 1.8. When you lot compile a Java source file, it creates a class file as well as add together the degree file version into it. In lodge to run that degree file, your JRE must empathize that version. When JRE or JVM which is running the degree doesn't able to empathize the degree file version they throw java.lang.UnsupportedClassVersionError: XXX : Unsupported major.minor version 51.0 error, where XXX is the cite of your degree which has an incompatible version.



Solution i - Upgrade JRE

Simplest solution to cook Unsupported major.minor version 51.0 fault changes your Java virtual machine. Upgrade JRE to acquire a version same or higher than the version you lot bring used for compiling your project. Once you lot got that, only run your plan again. It should locomote 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 ask to install 32-bit or 64-bit JDK 1.7 or JRE 1.7 version depending upon whether you lot are running on 32-bit or 64-bit OS e.g. If you lot are running on Windows seven or Windows 8 thus install a 64-bit version of JDK. You would also last fine if you lot are running on Java 8, but don't run the plan on Java half dozen or lower version.



Solution 2 - Use javac -target option

As you lot know forthwith that rootage drive of any java.lang.UnsupportedClassVersionError: Unsupported major.the tyke version is incompatible JRE version at run-time, but changing JRE is non the entirely solution you lot have, you lot tin fifty-fifty compile your degree file for lower JRE version. In lodge to adjust this solution, you lot ask to re-compile your project.

If recompilation is an pick thus brand certain you lot add together -target pick to javac alongside corresponding Java version you lot are looking every bit target runtime. For example, if you lot are generating degree file to run on Java 6, you lot tin locomote yesteryear the next declaration to javac command :

javac -target 1.6 *.java

*.java is to compile all Java files as well as target 1.6 way the degree file volition last compatible alongside Java SE half dozen JVM. If you lot desire to compile a degree file for Java 5, only role -target 1.5 option. See Core Java Volume i tenth Edition yesteryear Cay S. Horstmann for to a greater extent than special on Java compiler.

 fault comes when you lot run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inward Java



How to cook Unsupported major.minor version 51.0 inward Eclipse

If you lot are getting Unsupported major.minor version 51.0 error spell running your projection inward Eclipse, thus you lot ask to alter compiler pick for your projection inward Eclipse. This genuinely happens when you lot bring a projection specific compiler version setting but running on Eclipse's default JRE. If you lot afterwards changed Eclipse default JRE from JDK 1.7 to JDK 1.6, you lot volition run 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 inward thread "main" 


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

1. Select project, correct click, select properties

2. Select Java Compiler option, every bit shown below, you lot volition run across that JDK 1.7 was selected yesteryear default

 fault comes when you lot run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inward Java


3. Check the checkbox "Enable projection specific settings"

4. Choose the Compiler compliance flat you lot want, every bit shown below :

 fault comes when you lot run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inward Java


Choose 1.6 if you lot desire to run your plan on Java half dozen JVM, lead 1.7 if you lot desire to execute your Java plan alongside JRE 1.7 etc.

Alternatively, you lot tin also alter the JRE version inward Run Configuration yesteryear doing next steps :

1. Click on Run Menu as well as thus lead 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 you lot run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inward Java



3. Select the JRE tab, if you lot are already getting this fault thus you lot would run across the crimson cross on the tab, alarm you lot close a mismatch JRE version.

4. Just select the correct JRE version to run your plan i.e. if you lot are compiling using JDK seven thus lead Java seven here.
 fault comes when you lot run a degree file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inward Java


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

That's all close how to solve Unsupported major.minor version 51.0 fault inward Java and, inward particular, Eclipse IDE. Once you lot know the rootage drive it becomes slowly 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, you lot ask to customize corresponding describe of piece of job e.g. inward ANT, in that place is a javac describe of piece of job to compile source file, only furnish target parameter to it to solve this problem.

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

Related debugging tutorials

If you lot similar this tutorial as well as wants to acquire to a greater extent than close troubleshooting errors as well as exception inward Java, only depository fiscal establishment check only about of my before tutorials as well as debugging guide. You volition acquire rootage drive of many mutual Java problems as well as tips to solve them :
  • How to cook Unsupported major.minor version 52.0 fault inward 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 drive of  java.lang.ClassNotFoundException: com.mysql.jdbc.Drive fault inward Java? [solution]
  • Cause as well as solution of java.sql.SQLException: No suitable driver : sqljdbc4.jar [solution]
  • Root drive java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver inward Java? [analysis]

Komentar

Postingan populer dari blog ini

Common Multi-Threading Mistakes Inwards Coffee - Calling Run() Instead Of Start()

3 Examples Of Parsing Html File Inwards Coffee Using Jsoup

Why You Lot Should Command Visibility Of Shape Too Interface Inward Java