I need to get all the .class files located in a .jar file which in turn is located within another .ear file.
I am trying to use the JarInputStream to get access to the .ear. This is working ok. However, when I iterate the JarEntry elements inside the JarInputStream, I can't seem to be able to open it as a Jar file in order to read any .class elements within it.
JarInputStream jarFile = new JarInputStream(new FileInputStream("c:/path/to/my/.ear"));
JarEntry jarEntry = null;
while(true) {
jarEntry = jarFile.getNextJarEntry();
if(jarEntry == null) {
break;
}
if((jarEntry.getName().endsWith(".jar"))) {
//Access to the nested jar?
}
}
Edited: worth mentioning that the code above is in the same jar as the classes I am trying to find programmatically.