Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat can cause a 'Could not find the main class' when packaging a jar?
    text
    copied!<p>I'm participating in an open source project, where I've got my own repo for the modification I'm working on.</p> <p>I've added new features over the last couple of months while always testing the functionalities from within eclipse. Now that everything is ready, I wanted to make a release, built the windows installer with the ant script which always produced a working installer, but after installation, when launching the application a information window with this message is being displayed right away.</p> <p>Java Virtual Machine Launcher Could not find the main class: net.pms.PMS. Program will exit. OK</p> <p>I can't figure out what change has been made to break the packaging.</p> <p>Some facts:</p> <ul> <li>To build the installer, an <a href="http://pms-mlx.svn.sourceforge.net/viewvc/pms-mlx/trunk/ps3mediaserver_mlx/build.xml?revision=48&amp;view=markup" rel="nofollow noreferrer">ANT script</a> calling two NSIS scipts is being used. It's the ANT script which is packaging the jar. These scripts haven't changed between the two versions. The manifest for the main method (net.pms.PMS) is being set in the ANT script.</li> <li>Quite a big amount of code has changed between the two versions; as the main class not found error is being shown right away when starting the application I tend to think neither the changed code nor changed imports for jars can provoke that!?</li> <li>The class files containg the main class are included in the package and I promise PMS.java contains a main method <img src="https://i.stack.imgur.com/t2taC.png" alt="pms-mlx jar content"></li> <li>It doesn't matter how the application is being started; exe launcher, <a href="http://pms-mlx.svn.sourceforge.net/viewvc/pms-mlx/trunk/ps3mediaserver_mlx/PMS.bat?revision=48&amp;view=markup" rel="nofollow noreferrer">batch file</a> or command line, the main class not found always shows up.</li> <li>I had installed the jdk7. As it might have been conflicting with jdk6, I've uninstalled everyting related to 7 and currently run jdk6_29</li> <li>A plugin system is available in the application, where plugins get loaded from a folder dynamically on runtime <a href="http://pms-mlx.svn.sourceforge.net/viewvc/pms-mlx/trunk/ps3mediaserver_mlx/net/pms/medialibrary/external/ExternalFactory.java?revision=48&amp;view=markup" rel="nofollow noreferrer">ExternalFactory</a>. The way this being done has changed quite a bit. Again, as it is during runtime, I can't imagine something in there could provoke the problem.</li> <li>I can't find any information either in the windows event log, haven't found any java logs and the application logs obviously aren't initialized at all.</li> </ul> <p>I'm currently clueless what change I've made provokes this main class not found error. I'd be really grateful if someone could point me into the right direction with some clues where I could get some useful information from or what is actually going on.</p> <p>Thanks, Philippe</p> <p>[edit] Some additions related to the posted comments:</p> <p>Contents of MANIFEST.MF:<br> Manifest-Version: 1.0<br> Ant-Version: Apache Ant 1.8.2<br> Created-By: 1.6.0_29-b11 (Sun Microsystems Inc.)<br> Main-Class: net.pms.PMS</p> <p>How is the application started:<br> If launched with the batch: javaw -Xmx768M -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -classpath update.jar;pms.jar net.pms.PMS<br> exe generated with NSIS: -classpath update.jar;pms.jar -Xmx1024M -Dsun.java2d.d3d=false -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 ${CLASS} $1<br></p> <p>When trying to launch it with 'java -cp pms.jar net.pms.PMS' an intersting stack trace shows up<br> <code>C:\Program Files (x86)\PS3 Media Server MLX>java -cp pms.jar net.pms.PMS Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source) at sun.security.util.SignatureFileVerifier.process(Unknown Source) at java.util.jar.JarVerifier.processEntry(Unknown Source) at java.util.jar.JarVerifier.update(Unknown Source) at java.util.jar.JarFile.initializeVerifier(Unknown Source) at java.util.jar.JarFile.getInputStream(Unknown Source) at sun.misc.JarIndex.getJarIndex(Unknown Source) at sun.misc.URLClassPath$JarLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.misc.URLClassPath$JarLoader.ensureOpen(Unknown Source) at sun.misc.URLClassPath$JarLoader.(Unknown Source) at sun.misc.URLClassPath$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.misc.URLClassPath.getLoader(Unknown Source) at sun.misc.URLClassPath.getLoader(Unknown Source) at sun.misc.URLClassPath.getResource(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) Could not find the main class: net.pms.PMS. Program will exit.</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload