I am trying to create a jar file having following project contents
- Project
- user_interface (package folder including all .classes related to GUI)
- function_operations (package folder including all .classes related to operations)
- sounds (folder include all sound files)
- icons (include all images and icons)
- jars (include all external jar files)
- manifest.txt (having one line *Main-Class: user_interface.messengerGUI* and two enters)
i m using command
jar cvfm helloBuddy.jar manifest.txt user_interface/*.class function_operations/*.class icons/ sounds/
It successfully create jar file but gives following error while executing
JAI-MATA-DI-LINUX Project # java -jar helloBuddy.jar Exception in thread "main" java.lang.NoClassDefFoundError: user_interface/messengerGUI Caused by: java.lang.ClassNotFoundException: user_interface.messengerGUI at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: user_interface.messengerGUI. Program will exit.
another problem is how to include external jars?
Edited: finaly some success to jar formation. Using eclipse i am able to create jar file. But when i run it gives the following error
Exception in thread "main" java.lang.NoClassDefFoundError: org/jivesoftware/smack/ChatManagerListener Caused by: java.lang.ClassNotFoundException: org.jivesoftware.smack.ChatManagerListener at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: user_interface.messengerGUI. Program will exit.
I have included few external jar files in project. org/jivesoftware/smack/ChatManagerListener this class belongs to one of the smackx.jar file. so this error is of external jar files added to project. any clue how can i resolve this?
jar -tvf helloBuddy.jar
? Copy/past it into the question as an edit and use code formatting. – Andrew Thompsonuser_interface/*.class
you be writinguser_interface
ifuser_interface
is the package which contains all the .class files. – nIcE cOw