1 23 24 29 30 package com.sun.enterprise.util.diagnostics; 31 import com.sun.enterprise.util.diagnostics.Reporter; 32 import java.util.*; 33 34 39 40 public class Classpath 41 { 42 public static List getClasspathAsList() 43 { 44 String cp = getClasspathAsString(); 45 String ps = System.getProperty("path.separator"); 46 StringTokenizer st = new StringTokenizer(cp, ps); 47 List list = new ArrayList(); 48 49 while (st.hasMoreTokens()) 50 { 51 list.add(st.nextToken()); 52 } 53 54 return list; 55 } 56 57 public static List getClasspathAsBatchCommands() 58 { 59 List from = getClasspathAsList(); 60 List to = new ArrayList(); 61 62 boolean first = true; 63 64 for(Iterator iter = from.iterator(); iter.hasNext(); ) 65 { 66 if(first) 67 { 68 to.add("set CLASSPATH=" + iter.next()); 69 first = false; 70 } 71 else 72 to.add("set CLASSPATH=%CLASSPATH%;" + iter.next()); 73 } 74 75 return to; 76 } 77 78 public static String getClasspathAsString() 79 { 80 return System.getProperty("java.class.path"); 81 } 82 83 public static List getClasspathAsSortedList() 84 { 85 List list = getClasspathAsList(); 86 Collections.sort(list, String.CASE_INSENSITIVE_ORDER); 87 return list; 88 } 89 90 91 public static void main(String [] args) 92 { 93 pr("****** CLASSPATH as String *******"); 94 pr(getClasspathAsString()); 95 pr("****** CLASSPATH as List *******"); 96 pr(getClasspathAsList()); 97 pr("****** CLASSPATH as Sorted List *******"); 98 pr(getClasspathAsSortedList()); 99 pr("****** CLASSPATH as Batch Commands *******"); 100 pr(getClasspathAsBatchCommands()); 101 } 102 103 private static void pr(String s) 104 { 105 System.out.println(s); 106 } 107 108 private static void pr(List c) 109 { 110 for(Iterator iter = c.iterator(); iter.hasNext(); ) 111 { 112 pr((String )iter.next()); 113 } 114 } 115 116 } 117 | Popular Tags |