Java checks compiled version of *.class files

Use the javap command of jdk to check the compilation information of the class file, which is useful for checking the version information when the old and new versions of java software coexist.

 

Enter the main directory of the compiled class file, enter the command , the command format is similar (class package-info.class, in the package com.test):

>javap -verbose F:\com\test\package-info.class

 

Output information:


com/test/package-info.class
  Last modified 2017-11-15; size 347 bytes
  MD5 checksum 2e8541a841a4605a15e6baf5403ba5b9
  Compiled from "package-info.java"
interface com.test.package-info
  SourceFile: "package-info.java"
  RuntimeVisibleAnnotations:
    0: #8(#9=s#10,#11=e#12.#13)
  minor version: 0 major version: 50  flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_SYNTHETICConstant pool:
 

......

 

Note:

================================
major version: 50 corresponds to JDK1.6 (decimal 51 corresponds to jdk1.7 , 49 Corresponding to jdk1.5, 52 corresponds to jdk1.8)
=================================
or use EMEDITOR to ten Open the .class file in hexadecimal, check the fourth byte, 0x32 means decimal 50, that is, the compilation target version is jdk1.6

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326536799&siteId=291194637