We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Problem starting an application in a jar
Page Index Toggle Pages: 1
Problem starting an application in a jar (Read 524 times)
Problem starting an application in a jar
Dec 8th, 2008, 1:34pm
 
Hello

My application that embeds PAppet works OK when invoked with

java -classpath XXX mapackage.MyApp

However, it stops working when I pack my classes into a jar file and invoke the application like this

java -classpath XXX -jar myapp.jar.

There is no problem with the jar file, ie without the PApplet embedded the application starts up OK.  If I interprest the error message correctly, the problem seem to be that PApplet cannot find the main class despite the fact that the jar file with the main class is on the classpath.

Any suggestions will be appreciated

The error folows below:

Exception in thread "main" java.lang.NoClassDefFoundError: processing/core/PApplet
       at java.lang.ClassLoader.defineClass1(Native Method)
       at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
       at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
       at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
       at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
       at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Caused by: java.lang.ClassNotFoundException: processing.core.PApplet
       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
       ... 12 more
Could not find the main class: npgviz.npgviewer.NpgVizFrame. Program will exit.

Re: Problem starting an application in a jar
Reply #1 - Dec 8th, 2008, 2:05pm
 
What is XXX? Is core.jar in it?
Re: Problem starting an application in a jar
Reply #2 - Dec 8th, 2008, 2:43pm
 
Yes, the core .jar is in it
Page Index Toggle Pages: 1