If that's not possible, use Java compiler's cross compilation option to generate class file for your production Java/JRE version using javac -target option. Make sure to install the same JDK version for building your Java application as you are going to run in production. your production is running on JDK 1.6 and your latest release is failing due to "Unsupported major.minor version 52.0" error then you need to fix your build environment. If you cannot upgrade to higher Java version e.g. Remember, difference between PATH and CLASSPATH. You don't need to touch your CLASSPATH, because its not a classpath issue. To fix this, examine your PATH environment variable and make sure the latest version of Java comes first. If you have multiple JRE version installed then lower version is coming ahead in PATH than higher version. If you already installed the JDK 1.8 then its due to incorrect PATH setting. If you are getting " HelloWorld unsupported major.minor version 52.0", which means Java version in your PATH is lesser than Java 8. Solution of Unsupported major.minor version 52.0 Error in JavaĪs I said earlier, there are two ways to fix "Unsupported major.minor version 52.0" error, first upgrade to higher Java version or compiler Java source files for lower Java version of target environment. ![]() The Helloworld.class file generated by this command can be run in any version of Java 1.4 onward e.g. So, for example, you can generate a Java class file for JDK 1.4 by running javac command with -target option as shown below : Same is the case with an applet compiled in JDK 1.8, running in a browser with JRE 1.7.īTW, Java allows you to generate class files supported by lower version. If you run this class file in JRE 7, you will get "Unsupported major.minor version 52.0". You can see that Java 8 has major version 52, which means if you run javac command from Java 8 installation, it will by default generate a class with major version 52. Here are the major version of every JRE released so far : Anyway, even if you are not using features which is not supported in a lower version, every class file has a major or minor version, which is populated by Java compiler, which is closely related to Java version. Think about, can you run lambda expression or Stream API code in Java 5, no right. Java 8, but it doesn't mean that you can run a class compiled using Java 7 into Java 5, Why? because higher version usually have features which are not supported by the lower version. Well, it's true that Java is backward compatible, which means you can run a Java class file or Java binary (JAR file) compiled in lower version (java 6) into higher version e.g. Many people think why do you get a version mismatch error if Java is backward compatible. TL:DR upgrade to Java 8 or compile for lower JRE version using java -target 1.6 option.Ĭause of Unsupported major.minor version 52.0 Error in Java Let's understand the cause and solution of Unsupported major.minor version 52.0 Error in little more detail. ![]() ![]() The Main reason of this error is that during compilation, you have used a higher version of JDK but during deployment, you have deployed into a lower version of JDK or JRE. You can get " unsupported major.minor version 52.0" while running a Java program explicitly using java command or running a Java Applet in browser or running a Java program from command line but compiled in Eclipse or any other build tool like Maven or ANT. If you have multiple JRE installed make sure that the latest one comes first in PATH environment variable. If upgrading to Java 8 is not an option then make sure you use Java compiler's cross compilation feature and compile source code for lower Java version by using -target option of javac command. Simplest way to fix this error is install the latest Java release i.e. Unsupported major.minor version 52.0 comes when you are trying to run a class compiled using Java 1.8 compiler into a lower JRE version e.g.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |