11/5/2022 0 Comments Java ver 1.8![]() (even using target, Java 1.8 only classes can sneak in)Īuthor Fabian Posted on JanuSeptemCategories Java Tags bad, class, compile, java, javap, major, minor, run, should be, version, wrong Post navigation Īlternatively, you can use the ‘’ in the element. If a project uses Maven, then the way to specify the JVM compatibility is in the pom.xml ‘maven-compiler-plugin’ section. If you target a lower JVM, it is important that no features/packages from the newer specification are used.įor example, even if the ‘javac’ being used below is from a 1.8 JVM, it can still create 1.7 compatible class files if you use the parameters below. #Java ver 1.8 code$ od -format=d1 M圜lass.class -j 7 -N 1Ġ000007 51 0000011 Compiling to lower versionsĮven if you are using a newer JDK, you can still compile code compatible with older JVM specifications by using the ‘-target’ parameter. Using Linux, this is easily done using the ‘od’ dump standard utility. If you don’t have access to javap, you can also using a console based utility or GUI hex editor to look at the value of the byte at position 7 in the file. Windows: > javap -verbose M圜lass | findstr "major" Linux: $ javap -verbose M圜lass | grep "major" ![]() Note that a JRE (runtime) will not have this utility available. If you have a JDK (Java Development Kit) installed on your machine, then you can use ‘javap’ to look into the class file. ![]() This major version number is stored in the header of the. Here is a table of the JVM versions mapped to the corresponding major version: JVM In these cases, you can look for older versions of the library or if the project is open-source, you can investigate recompiling at a lower level as long as newer features and packages are not utilized. #Java ver 1.8 upgradeThe error message indicates ‘should be XX.0’, and the table below shows which JVM to use.īut there are also times when for security reasons or enterprise standards, that you cannot upgrade your JVM just to accommodate a single class or library. ![]() The easiest way to resolve this issue is to simply move up the higher Java version expected. The good news is that this is a relatively simple issue to address. class file was compiled as a Java 1.8 class file on a Jenkins continuous integration node, but the JRE on the desktop where you want to run it only has Java 1.7, then you will get this message when you attempt to run it. If a Java class file is compiled with a higher supported version than is currently being run, you will get the ‘bad class file’, ‘class file has the wrong version XX.0, should be XX.0’ error message.įor example, if the. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |