package org.oklab; import java.util.*; import java.util.jar.*; import java.io.IOException; /** * 1.Systemプロパティのsun.boot.class.pathからライブラリの文字列取得 * 2.ライブラリをStringTokenizerで解析 * 3.表示 * * @author satoshiokita * @version 取り合えず動く */ public class Gets { public static void main(String[] args) { Gets g = new Gets(); g.doMethod(); } private void doMethod() { Properties properties = System.getProperties(); Enumeration enum = properties.propertyNames(); while (enum.hasMoreElements()) { String key = (String)enum.nextElement(); //System.out.println(key + ":" + properties.getProperty(key) ); if (key.equals("sun.boot.class.path")) { parse(properties.getProperty(key)); } } } private void parse(String value) { System.out.println(value); StringTokenizer st = new StringTokenizer(value, ";"); while(st.hasMoreTokens()) { String lib = st.nextToken(); //System.out.println(lib); viewClass(lib); } } private void viewClass(String value) { try { JarFile jar = new JarFile(value); Enumeration enum = jar.entries(); while (enum.hasMoreElements()) { JarEntry j = (JarEntry)enum.nextElement(); System.out.println(j); } } catch (IOException ex) { ex.printStackTrace(); } catch (SecurityException ex) { ex.printStackTrace(); } } }