The NoteBook of EricKong

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            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) 評(píng)論(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  回復(fù)  更多評(píng)論
            

          # 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  回復(fù)  更多評(píng)論
            

          # 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  回復(fù)  更多評(píng)論
            

          主站蜘蛛池模板: 基隆市| 玛多县| 刚察县| 淮滨县| 高邑县| 深州市| 景东| 都江堰市| 苗栗市| 自贡市| 新郑市| 通榆县| 阿勒泰市| 凤翔县| 云安县| 十堰市| 广汉市| 马山县| 湖北省| 内丘县| 丰台区| 闸北区| 琼中| 和静县| 张家口市| 本溪| 叶城县| 甘洛县| 桑日县| 石阡县| 万盛区| 兖州市| 抚顺县| 商洛市| 且末县| 天门市| 邮箱| 威宁| 颍上县| 富蕴县| 安宁市|