The NoteBook of EricKong

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            611 Posts :: 1 Stories :: 190 Comments :: 0 Trackbacks
          import java.io.*; 
          public class ClassVersionChecker { 
          public static void main(String[] args) throws IOException { 
             
          for (int i = 0; i < args.length; i++) 
                  checkClassVersion
          (args[i]); 
          } 
           
             
          private static void checkClassVersion(String filename) 
                 
          throws IOException 
             
          { 
                 
          DataInputStream in = new DataInputStream 
                   
          (new FileInputStream(filename)); 
           
                 
          int magic = in.readInt(); 
                 
          if(magic != 0xcafebabe) { 
                   
          System.out.println(filename + " is not a valid class!");; 
                 
          } 
                 
          int minor = in.readUnsignedShort(); 
                 
          int major = in.readUnsignedShort(); 
                 
          System.out.println(filename + ": " + major + " . " + minor); 
                 
          in.close(); 
             
          } 
          } 

          The possible values are :

          major  minor Java platform version  
          45       3           1.0 
          45       3           1.1 
          46       0           1.2 
          47       0           1.3 
          48       0           1.4 
          49       0           1.5 
          50       0           1.6 
          posted on 2010-12-10 17:42 Eric_jiang 閱讀(266) 評論(3)  編輯  收藏 所屬分類: Java

          Feedback

          # re: Java API to find out the JDK version a class file is compiled for 2010-12-23 13:24 Eric_jiang
          http://www.webspherechina.net/club/thread-16869-1-1.html  回復  更多評論
            

          # re: Java API to find out the JDK version a class file is compiled for 2010-12-23 13:26 Eric_jiang
          http://www.webspherechina.net/club/thread-7698-1-1.html  回復  更多評論
            

          # re: Java API to find out the JDK version a class file is compiled for 2010-12-23 13:26 Eric_jiang
          http://www.webspherechina.net/club/thread-14072-1-1.html  回復  更多評論
            

          主站蜘蛛池模板: 饶平县| 雷州市| 图们市| 商水县| 绥德县| 万全县| 三穗县| 池州市| 微山县| 冀州市| 林甸县| 孟州市| 石台县| 化德县| 山阴县| 贡嘎县| 陇西县| 内丘县| 中江县| 石狮市| 库伦旗| 贵定县| 大丰市| 岚皋县| 枣庄市| 广南县| 高邑县| 德安县| 隆化县| 桐柏县| 米易县| 定边县| 秀山| 西乌珠穆沁旗| 那曲县| 拉孜县| 射洪县| 青铜峡市| 高青县| 山东省| 夏津县|