I created a JAR file from Eclipse IDE. The classes in the JAR contains applet and Swing code. The usual basic problem is happening when i double click the JAR file,
"Could not find the main class. Program will exit".
Following are the things i ensured:
(1) System's environment variable PATH has this value: C:\Program Files\Java\jdk1.5.0_12.
(2) I opened the MANIFEST.MF file and added the Main-Class and Class-Path attributes
(3) Entered a carriage return at the end of the MANIFEST.MF file.
(4) I also added the JRE path to the PATH environment variable.
The Main-Class attribute in the META-INF/MANIFEST.MF given contains the fully qualified name com.test.MainClass
The main class is packaged properly with the com/test/ package structure.
The main class contains the package com.test; statement.
Although i exported the JAR file from Eclipse IDE, i ensured that all the classes are properly packaged into the JAR with the correct package structure.
If you are using Eclipse, you can let eclipse create the manifest file for you.
At the tail end of the wizard (project->export->jar), depending on version, you will be asked if Eclipse should create a manifest file. If you select that option, you will be asked for a main class. Try using eclipse to build the manifest file for you.
If you are able to get the jar running by this approach, compare the eclipse created manifest.mf and your manifest file to figure out what you did wrong.
Does your packaged jar contain the manifest.txt (only) in the META-INF directory and still work?
Thanks for spending your valuable time for solving my issue.
But unfortunately, i am still having that problem.
I created the JAR by export option from Eclipse. The MANIFEST.MF file was generated by Eclipse only. I didn't specify any particular file.
JAR file is searching only for Manifest.mf it doesn't understand manifest.txt!
Next thing i tried is creating the JAR file using jar command. I used the following command:
The com\ directory contains all the required class files to be packaged.
jar -cfm MyJar.jar C:\Manifest.txt com\
The Manifest.txt has the following entries:
The above entries are inserted into the Manifest.mf file created by the jar command.
I ensured that the classes in the JAR file contain the correct package structure.