 <p>Executing shell commands in programs isn't very nice in my opinion so what you can do is to inspect the file programmatically.</p> <p>Take this example, we'll fill classNames with the list of all Java classes contained inside a jar file at <code>/path/to/jar/file.jar.</code></p> <pre><code>List&lt;String&gt; classNames = new ArrayList&lt;String&gt;(); ZipInputStream zip = new ZipInputStream(new FileInputStream("/path/to/jar/file.jar")); for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) { if (!entry.isDirectory() &amp;&amp; entry.getName().endsWith(".class")) { // This ZipEntry represents a class. Now, what class does it represent? String className = entry.getName().replace('/', '.').replace('$',''); // including ".class" classNames.add(className.substring(0, className.length() - ".class".length())); } } </code></pre> <p>Credit: <a href="http://stackoverflow.com/questions/15720822/how-to-get-names-of-classes-inside-a-jar-file">Here</a></p>