October 22, 201015 yr Once I've got a jar loaded, is there a way to list its classes, etc. so I know what I can do with it?
October 23, 201015 yr The JAR file is just a ZIP file, so if you have, say, 7-zip installed, you can right click it an unzip it. Alternately, if the Java SDK is installed you can use the jar command to list the classes per Link You can list the classes in Scriptmaster by reading the jar file and parsing it. Below example shows classes in javax.mail, assuming you have a copy in c:mail.jar Most jars have a javadoc on the internet that lists all the classes. import java.util.jar.*; import java.util.*; import java.io.*; public static String getClasseNamesInPackage (String jarName, String packageName) { String classes = ""; packageName = packageName.replaceAll("." , "/"); try{ JarInputStream jarFile = new JarInputStream (new FileInputStream (jarName)); JarEntry jarEntry; while(true) { jarEntry=jarFile.getNextJarEntry (); if(jarEntry == null){ break; } if((jarEntry.getName ().startsWith (packageName)) && (jarEntry.getName ().endsWith (".class")) ) { classes = classes + (jarEntry.getName().replaceAll("/", ".")) + "n"; } } } catch( Exception e){ return e ; } return classes; } String Class_list = getClasseNamesInPackage ("C:/mail.jar", "javax.mail"); return Class_list;
Create an account or sign in to comment