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

Unsupported major.minor version 51.0 mistake comes when you lot run a cast file created using Java 1.7 (major version 51.0) into a lower JRE version e.g. JRE 6, v or 4. There are 2 ways to solve this problem, commencement brand certain you lot run your Java computer programme inwards same or higher version of JRE, on which it has compiled, in addition to minute piece of occupation cross-compilation pick to exercise a cast file compatible to a lower JRE. You tin plough over notice piece of occupation javac -target pick to exercise a cast 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 in addition to thence you lot tin plough over notice exercise cast files to run on JDK 1.1, 1.2, 1.3, 1.4 , 1.5 in addition to 1.6 version, but you lot cannot exercise cast files compatible amongst Java 1.8. When you lot compile a Java source file, it creates a class file in addition to add together the cast file version into it. In lodge to run that cast file, your JRE must sympathise that version. When JRE or JVM which is running the cast doesn't able to sympathise the cast file version they throw java.lang.UnsupportedClassVersionError: XXX : Unsupported major.minor version 51.0 error, where XXX is the advert of your cast which has an incompatible version.



Solution 1 - Upgrade JRE

Simplest solution to ready Unsupported major.minor version 51.0 mistake 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 computer programme again. It should piece of occupation fine this time. Since java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0 clearly says that this file needs, at least, Java vii or higher to run. You necessitate 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 vii or Windows 8 in addition to thence install a 64-bit version of JDK. You would also travel fine if you lot are running on Java 8, but don't run the computer programme on Java six or lower version.



Solution 2 - Use javac -target option

As you lot know directly that source drive of any java.lang.UnsupportedClassVersionError: Unsupported major.the fry version is incompatible JRE version at run-time, but changing JRE is non the alone solution you lot have, you lot tin plough over notice fifty-fifty compile your cast file for lower JRE version. In lodge to accommodate this solution, you lot necessitate to re-compile your project.

If recompilation is an pick in addition to thence brand certain you lot add together -target pick to javac amongst corresponding Java version you lot are looking equally target runtime. For example, if you lot are generating cast file to run on Java 6, you lot tin plough over notice top 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 cast file volition travel compatible amongst Java SE six JVM. If you lot desire to compile a cast file for Java 5, only piece of occupation -target 1.5 option. See Core Java Volume 1 tenth Edition yesteryear Cay S. Horstmann for to a greater extent than especial on Java compiler.

 mistake comes when you lot run a cast file created using Java  2 ways to solve Unsupported major.minor version 51.0 mistake inwards Java



How to ready Unsupported major.minor version 51.0 inwards Eclipse

If you lot are getting Unsupported major.minor version 51.0 error piece running your projection inwards Eclipse, in addition to thence you lot necessitate to alter compiler pick for your projection inwards Eclipse. This genuinely happens when you lot bring a projection specific compiler version setting but running on Eclipse's default JRE. If you lot subsequently changed Eclipse default JRE from JDK 1.7 to JDK 1.6, you lot volition encounter next mistake :

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 plough over notice encounter follow next steps to solve Unsupported major.minor version 51.0 mistake inwards Eclipse IDE:

1. Select project, correct click, select properties

2. Select Java Compiler option, equally shown below, you lot volition encounter that JDK 1.7 was selected yesteryear default

 mistake comes when you lot run a cast file created using Java  2 ways to solve Unsupported major.minor version 51.0 mistake inwards Java


3. Check the checkbox "Enable projection specific settings"

4. Choose the Compiler compliance aeroplane you lot want, equally shown below :

 mistake comes when you lot run a cast file created using Java  2 ways to solve Unsupported major.minor version 51.0 mistake inwards Java


Choose 1.6 if you lot desire to run your computer programme on Java six JVM, lead 1.7 if you lot desire to execute your Java computer programme amongst JRE 1.7 etc.

Alternatively, you lot tin plough over notice also alter the JRE version inwards Run Configuration yesteryear doing next steps :

1. Click on Run Menu in addition to and thence lead Run Configurations equally shown below

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

 mistake comes when you lot run a cast file created using Java  2 ways to solve Unsupported major.minor version 51.0 mistake inwards Java



3. Select the JRE tab, if you lot are already getting this mistake in addition to thence you lot would encounter the blood-red cross on the tab, alarm you lot close a mismatch JRE version.

4. Just select the correct JRE version to run your computer programme i.e. if you lot are compiling using JDK vii in addition to thence lead Java vii here.
 mistake comes when you lot run a cast file created using Java  2 ways to solve Unsupported major.minor version 51.0 mistake inwards Java


Once you lot brand this change, you lot tin plough over notice only run your Java application in addition to 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 mistake inwards Java and, inwards particular, Eclipse IDE. Once you lot know the source drive it becomes slow to solve the problem, it's e'er a mismatch betwixt Java version at compile in addition to run-time.  You tin plough over notice also acquire unsupported major.minor version 51.0 error from your construct tool e.g. Maven in addition to ANT. Since they internally piece of occupation javac compiler to compile the file, you lot necessitate to customize corresponding business e.g. inwards ANT, at that topographic point is a javac business to compile source file, only render target parameter to it to solve this problem.

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

Related debugging tutorials

If you lot similar this tutorial in addition to wants to larn to a greater extent than close troubleshooting errors in addition to exception inwards Java, only cheque closed to of my before tutorials in addition to debugging guide. You volition larn source drive of many mutual Java problems in addition to tips to solve them :
  • How to ready Unsupported major.minor version 52.0 mistake inwards Java [solution]
  • Failed to connect to Queue using WebSphere MQ Series mistake [solution]
  • How to fix java.lang.classnotfoundexception sun.jdbc.odbc.jdbcodbcdriver erorr [solution]
  • Solution of JDBC mistake 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 mistake inwards Java? [solution]
  • Cause in addition to solution of java.sql.SQLException: No suitable driver : sqljdbc4.jar [solution]
  • Root drive java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver inwards Java? [analysis]

Sumber https://javarevisited.blogspot.com/

0 Response to "2 Ways To Solve Unsupported Major.Minor Version 51.0 Fault Inwards Java"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel