This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm new to java and I'm trying to make an executable jar file with no luck so far. My OS is windows xp.
I have my compiled class file: GuiDemo.class located at C:\Java Projects\bin\com\test\common. I created a manifest file: GuiDemo.mf at the same location which has the below contents and a blank line at the end of the manifest file.
The above command did create an executable jar file: GuiDemo.jar, which I tested using C:\Java Projects\bin\com\test\common>jar -tf GuiDemo.jar and it gave the following result.
But, when I try to execute the jar file using: C:\Java Projects\bin\com\test\common>java -jar GuiDemo.jar, it is giving NoClassDefFound exception and the last line says: Could not find the main class: com.test.common.GuiDemo.class. Program will exit.
My CLASSPATH is set as C:\Java Projects\bin. I can execute GuiDemo without any issues using C:\>java com.test.common.GuiDemo
The classes inside your JAR file must be placed in a directory structure that matches the package declarations. In this case, your JAR file must contain a folder com\test\common and the GuiDemo.class file must be placed inside that folder.