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

Unsupported major.minor version 51.0 fault comes when yous run a flat 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, offset brand certain yous run your Java programme inwards same or higher version of JRE, on which it has compiled, in addition to instant role cross-compilation selection to produce a flat file compatible to a lower JRE. You tin role javac -target selection to produce a flat file for all JRE up-to-the JDK version yous are using for compilation. For example, if yous are compiling your Java source file into JDK 1.7 hence yous tin produce flat files to run on JDK 1.1, 1.2, 1.3, 1.4 , 1.5 in addition to 1.6 version, but yous cannot produce flat files compatible alongside Java 1.8. When yous compile a Java source file, it creates a class file in addition to add together the flat file version into it. In guild to run that flat file, your JRE must empathise that version. When JRE or JVM which is running the flat doesn't able to empathise the flat file version they throw java.lang.UnsupportedClassVersionError: XXX : Unsupported major.minor version 51.0 error, where XXX is the refer of your flat 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 yous convey used for compiling your project. Once yous got that, simply run your programme again. It should move 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 yous are running on 32-bit or 64-bit OS e.g. If yous are running on Windows seven or Windows 8 hence install a 64-bit version of JDK. You would also endure fine if yous are running on Java 8, but don't run the programme on Java half-dozen or lower version.



Solution 2 - Use javac -target option

As yous know directly that origin crusade of any java.lang.UnsupportedClassVersionError: Unsupported major.the shaver version is incompatible JRE version at run-time, but changing JRE is non the exclusively solution yous have, yous tin fifty-fifty compile your flat file for lower JRE version. In guild to conform this solution, yous ask to re-compile your project.

If recompilation is an selection hence brand certain yous add together -target selection to javac alongside corresponding Java version yous are looking equally target runtime. For example, if yous are generating flat file to run on Java 6, yous tin move yesteryear the next declaration to javac command :

javac -target 1.6 *.java

*.java is to compile all Java files in addition to target 1.6 agency the flat file volition endure compatible alongside Java SE half-dozen JVM. If yous desire to compile a flat file for Java 5, simply role -target 1.5 option. See Core Java Volume i tenth Edition yesteryear Cay S. Horstmann for to a greater extent than item on Java compiler.

 fault comes when yous run a flat file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java



How to cook Unsupported major.minor version 51.0 inwards Eclipse

If yous are getting Unsupported major.minor version 51.0 error land running your projection inwards Eclipse, hence yous ask to alter compiler selection for your projection inwards Eclipse. This genuinely happens when yous convey a projection specific compiler version setting but running on Eclipse's default JRE. If yous subsequently changed Eclipse default JRE from JDK 1.7 to JDK 1.6, yous volition run into 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 run into 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, equally shown below, yous volition run into that JDK 1.7 was selected yesteryear default

 fault comes when yous run a flat 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 flat yous want, equally shown below :

 fault comes when yous run a flat file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java


Choose 1.6 if yous desire to run your programme on Java half-dozen JVM, direct 1.7 if yous desire to execute your Java programme alongside JRE 1.7 etc.

Alternatively, yous tin also alter the JRE version inwards Run Configuration yesteryear doing next steps :

1. Click on Run Menu in addition to hence direct Run Configurations equally shown below

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

 fault comes when yous run a flat file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java



3. Select the JRE tab, if yous are already getting this fault hence yous would run into the ruby-red cross on the tab, alarm yous close a mismatch JRE version.

4. Just select the correct JRE version to run your programme i.e. if yous are compiling using JDK seven hence direct Java seven here.
 fault comes when yous run a flat file created using Java  2 ways to solve Unsupported major.minor version 51.0 fault inwards Java


Once yous brand this change, yous tin simply run your Java application in addition to it should run fine, without whatsoever 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 inwards Java and, inwards particular, Eclipse IDE. Once yous know the origin crusade it becomes slowly to solve the problem, it's ever a mismatch betwixt Java version at compile in addition to run-time.  You tin also acquire unsupported major.minor version 51.0 error from your produce tool e.g. Maven in addition to ANT. Since they internally role javac compiler to compile the file, yous ask to customize corresponding describe of piece of job e.g. inwards ANT, at that spot is a javac describe of piece of job to compile source file, simply supply target parameter to it to solve this problem.

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

Related debugging tutorials

If yous similar this tutorial in addition to wants to larn to a greater extent than close troubleshooting errors in addition to exception inwards Java, simply banking concern check about of my before tutorials in addition to debugging guide. You volition larn origin crusade of many mutual Java problems in addition to tips to solve them :
  • How to cook 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 crusade of  java.lang.ClassNotFoundException: com.mysql.jdbc.Drive fault inwards Java? [solution]
  • Cause in addition to solution of java.sql.SQLException: No suitable driver : sqljdbc4.jar [solution]
  • Root crusade java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver inwards Java? [analysis]

0 Response to "2 Ways To Solve Unsupported Major.Minor Version 51.0 Mistake Inward Java"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel