title: How to print class and interface name from a java jar file
body: <p>I have a Jar in java which is containing 2 classes and 1 Interface. How can i get the interface and class names from the jar. Currently I am able to get the class names, but not the interface name.</p>
  
  <pre><code>   List jClasses = getClasseNames("D://Test.jar");
  
              System.out.println(jClasses.size());
  
              for (int i = 0; i &lt; jClasses.size(); i++) {
  
                  System.out.println("Print Classes ::" + jClasses.get(i));
  
                  if(( null != jClasses.getClass().getInterfaces()[i])) {
                      System.out.println(jClasses.getClass().getInterfaces()[i]);
                  } else {
                      System.out.println("No connection");
                  }
               }
  
     public static List getClasseNames(String jarName) {
          ArrayList classes = new ArrayList();
  
          try {
              JarInputStream jarFile = new JarInputStream(new FileInputStream(
                      jarName));
              JarEntry jarEntry;
  
              while (true) {
                  jarEntry = jarFile.getNextJarEntry();
                  if (jarEntry == null) {
                      break;
                  }
                  if (jarEntry.getName().endsWith(".class")) {
  
                      classes.add(jarEntry.getName().replaceAll("/", "\\."));
                  }
              }
          } catch (Exception e) {
              e.printStackTrace();
          }
          return classes;
      }
  </code></pre>
  
  <p>output :</p>
  
  <pre><code>Print Classes ::com.java.testclient.PTest1.class
  interface java.util.List
   ====== 
  Print Classes ::com.java.testclient.ClassSpy.class
  interface java.util.RandomAccess
   ====== 
  Print Classes ::com.java.testclient.myInt.class
  interface java.lang.Cloneable
   ====== 
  Print Classes ::com.java.testclient.PTest.class
  interface java.io.Serializable
  </code></pre>
  
  <p>Please suggest.</p>