2 Ways To Solve Unsupported Major.Minor Version 51.0 Fault Inwards Java
Unsupported major.minor version 51.0 mistake comes when yous run a course of pedagogy 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, starting fourth dimension brand certain yous run your Java plan inwards same or higher version of JRE, on which it has compiled, in addition to instant role cross-compilation choice to produce a course of pedagogy file compatible to a lower JRE. You tin forcefulness out role javac -target choice to produce a course of pedagogy 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 in addition to thence yous tin forcefulness out produce course of pedagogy 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 course of pedagogy files compatible alongside Java 1.8. When yous compile a Java source file, it creates a class file in addition to add together the course of pedagogy file version into it. In gild to run that course of pedagogy file, your JRE must empathize that version. When JRE or JVM which is running the course of pedagogy doesn't able to empathize the course of pedagogy file version they throw java.lang.UnsupportedClassVersionError: XXX : Unsupported major.minor version 51.0 error, where XXX is the mention of your course of pedagogy which has an incompatible version.
If recompilation is an choice in addition to thence brand certain yous add together -target choice to javac alongside corresponding Java version yous are looking every bit target runtime. For example, if yous are generating course of pedagogy file to run on Java 6, yous tin forcefulness out exceed the next declaration to javac command :
javac -target 1.6 *.java
*.java is to compile all Java files in addition to target 1.6 way the course of pedagogy file volition travel compatible alongside Java SE vi JVM. If yous desire to compile a course of pedagogy file for Java 5, only role -target 1.5 option. See Core Java Volume 1 tenth Edition yesteryear Cay S. Horstmann for to a greater extent than special on Java compiler.
You tin forcefulness out come across 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, every bit shown below, yous volition come across that JDK 1.7 was selected yesteryear default
3. Check the checkbox "Enable projection specific settings"
4. Choose the Compiler compliance flat yous want, every bit shown below :
Choose 1.6 if yous desire to run your plan on Java vi JVM, direct 1.7 if yous desire to execute your Java plan alongside JRE 1.7 etc.
Alternatively, yous tin forcefulness out also alter the JRE version inwards Run Configuration yesteryear doing next steps :
1. Click on Run Menu in addition to and thence direct Run Configurations every bit shown below
2. Choose your Java Application from left side listing of Java application which has run configuration
3. Select the JRE tab, if yous are already getting this mistake in addition to thence yous would come across the crimson cross on the tab, alarm yous virtually a mismatch JRE version.
4. Just select the correct JRE version to run your plan i.e. if yous are compiling using JDK seven in addition to thence direct Java seven here.
Once yous brand this change, yous tin forcefulness out 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 virtually how to solve Unsupported major.minor version 51.0 mistake inwards Java and, inwards particular, Eclipse IDE. Once yous know the rootage drive it becomes slow to solve the problem, it's ever a mismatch betwixt Java version at compile in addition to run-time. You tin forcefulness out also acquire unsupported major.minor version 51.0 error from your construct tool e.g. Maven in addition to ANT. Since they internally role javac compiler to compile the file, yous postulate to customize corresponding job e.g. inwards ANT, at that topographic point is a javac job to compile source file, only 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 1 in addition to 2
Core Java for the Impatient - Covers Java SE 8
Solution 1 - Upgrade JRE
Simplest solution to produce Unsupported major.minor version 51.0 mistake changes your Java virtual machine. Upgrade JRE to acquire a version same or higher than the version yous bring used for compiling your project. Once yous got that, only run your plan 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 postulate 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 in addition to thence install a 64-bit version of JDK. You would also travel fine if yous are running on Java 8, but don't run the plan on Java vi or lower version.Solution 2 - Use javac -target option
As yous know straightaway that rootage drive of any java.lang.UnsupportedClassVersionError: Unsupported major.the nipper version is incompatible JRE version at run-time, but changing JRE is non the alone solution yous have, yous tin forcefulness out fifty-fifty compile your course of pedagogy file for lower JRE version. In gild to accommodate this solution, yous postulate to re-compile your project.If recompilation is an choice in addition to thence brand certain yous add together -target choice to javac alongside corresponding Java version yous are looking every bit target runtime. For example, if yous are generating course of pedagogy file to run on Java 6, yous tin forcefulness out exceed the next declaration to javac command :
javac -target 1.6 *.java
*.java is to compile all Java files in addition to target 1.6 way the course of pedagogy file volition travel compatible alongside Java SE vi JVM. If yous desire to compile a course of pedagogy file for Java 5, only role -target 1.5 option. See Core Java Volume 1 tenth Edition yesteryear Cay S. Horstmann for to a greater extent than special on Java compiler.
How to produce Unsupported major.minor version 51.0 inwards Eclipse
If yous are getting Unsupported major.minor version 51.0 error piece running your projection inwards Eclipse, in addition to thence yous postulate to alter compiler choice for your projection inwards Eclipse. This genuinely happens when yous bring a projection specific compiler version setting but running on Eclipse's default JRE. If yous afterwards changed Eclipse default JRE from JDK 1.7 to JDK 1.6, yous volition come across 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 forcefulness out come across 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, every bit shown below, yous volition come across that JDK 1.7 was selected yesteryear default
3. Check the checkbox "Enable projection specific settings"
4. Choose the Compiler compliance flat yous want, every bit shown below :
Choose 1.6 if yous desire to run your plan on Java vi JVM, direct 1.7 if yous desire to execute your Java plan alongside JRE 1.7 etc.
Alternatively, yous tin forcefulness out also alter the JRE version inwards Run Configuration yesteryear doing next steps :
1. Click on Run Menu in addition to and thence direct Run Configurations every bit shown below
2. Choose your Java Application from left side listing of Java application which has run configuration
3. Select the JRE tab, if yous are already getting this mistake in addition to thence yous would come across the crimson cross on the tab, alarm yous virtually a mismatch JRE version.
4. Just select the correct JRE version to run your plan i.e. if yous are compiling using JDK seven in addition to thence direct Java seven here.
Once yous brand this change, yous tin forcefulness out 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 virtually how to solve Unsupported major.minor version 51.0 mistake inwards Java and, inwards particular, Eclipse IDE. Once yous know the rootage drive it becomes slow to solve the problem, it's ever a mismatch betwixt Java version at compile in addition to run-time. You tin forcefulness out also acquire unsupported major.minor version 51.0 error from your construct tool e.g. Maven in addition to ANT. Since they internally role javac compiler to compile the file, yous postulate to customize corresponding job e.g. inwards ANT, at that topographic point is a javac job to compile source file, only 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 1 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 acquire to a greater extent than virtually troubleshooting errors in addition to exception inwards Java, only depository fiscal establishment check around of my before tutorials in addition to debugging guide. You volition acquire rootage drive of many mutual Java problems in addition to tips to solve them :- How to produce 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]
Belum ada Komentar untuk "2 Ways To Solve Unsupported Major.Minor Version 51.0 Fault Inwards Java"
Posting Komentar