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 閱讀(267) 評論(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  回復  更多評論
            

          主站蜘蛛池模板: 阿拉善盟| 广安市| 封丘县| 抚远县| 平度市| 罗城| 钟祥市| 盖州市| 九江市| 阿克苏市| 河南省| 米泉市| 宝山区| 布拖县| 莫力| 教育| 桐城市| 大荔县| 丹巴县| 章丘市| 甘南县| 万安县| 司法| 平江县| 桂平市| 团风县| 阳信县| 图片| 深水埗区| 泰和县| 雅安市| 德昌县| 太仓市| 惠东县| 江孜县| 宜黄县| 丁青县| 昌邑市| 云南省| 临海市| 旬阳县|