Results 1 to 13 of 13
Thread: JAR Building Problem
- 09-25-2008, 05:09 PM #1
JAR Building Problem
um having problem in creating .jar for a project...i use Netbeans 6 IDE... i had no problem with the last project but this project gives me a main class not found error...i manually edited the manifest.mf file and compiled another .jar file but that gives me the same problem...i dont know what to do...this is the link to the project folder...can any one help me finding the problem??
link to the project:
filefactory.com/file/0ef240/n/TenderManagementSystem_rar
- 09-25-2008, 05:48 PM #2
How/What command do you issue to get the above error?project gives me a main class not found error
Can you post the full text of the error message?
Can you get to a commandprompt and enter:
java -jar <jarname>
What is in the manifest file in the jar file?
It should work if the jar file is found by the java command and the manifest file in the jar file has a Main-class: entry and the class pointed to by that entry is in the jar file with the correct package path.
- 09-25-2008, 06:42 PM #3
the full error text is:
could not find the main class. program will exit.
my manifest file is:
Manifest-Version: 1.2
Ant-Version: Apache Ant 1.7.0
Created-By: 1.4 (Sun Microsystems Inc.)
Main-Class: IndexFrame
Class-Path: lib/swingx-0.9.3.jar lib/AbsoluteLayout.jar lib/mysql-connector-java-5.1.6-bin.jar
output of the command java -jar "tendermanagementsystem.jar":
Exception in thread "main" java.lang.NoClassDefFoundError: IndexFrame
Caused by: java.lang.ClassNotFoundException: IndexFrame
at java.net.URClassLoader$1.run...........
.................................................. .......
.................................................. .......
can u please download and try building the jar...???Last edited by GhosT; 09-25-2008 at 06:44 PM.
- 09-25-2008, 07:22 PM #4
Look inside the jar file at the IndexFrame entry. It shouldn't be on any path. Is IndexFrame in a package? If so, the Main-Class: entry must include it.class pointed to by that entry is in the jar file with the correct package path.
Please don't edit the error message. There many be relevant info in it.................................................. .......
.................................................. .......
Sorry, I can't read rar files and I don't use an IDE.download and try building the jar
- 09-25-2008, 07:52 PM #5
class IndexFrame is in the jar file under tendermanagementsystem/IndexFrame.class, theres also an image folder. If i extract the jar i get 3 folders.
1. images
2. META-INFO (manifest.mf)
3. TenderManagementSystem (Contains *.class)
IndexFrame.class is there along with IndexFrame$1.class to IndexFrame$90.class files.
Previously i used jdk 6 update 1 and i was able to run jars only using a batch file, but double clicking didnt work...i updated to jdk 6 update 7 and changed the environment variables to match new jdk. now batch files also dont work...strange...
some other projects run fine...i just double click the jar ...tada.....but this project and another one just dont listen to me...:S
any help??
i suggest u to please compile/build and run the project using netbeans 6 IDE...thn u might find the problem...
- 09-25-2008, 08:45 PM #6
Is IndexFrame in a package? If so, the Main-Class: entry must include it.Main-Class: IndexFrameChange the Main-class: to include the package-pathtendermanagementsystem/IndexFrame.class
I don't use an IDE.suggest u to please compile/build and run the project using netbeans 6 IDE.
- 09-25-2008, 10:36 PM #7
i did but its all the same...manual build reduce the size of jar from 373KB (provided by netbeans) to 168KB...
i located the main class in the manifest and built
jar cfm manifest.mf tms.jar *.class
still same...
i need help from someone used to with netbeans...bacause that way i'll understand better...um a noob in java :D
- 09-26-2008, 12:01 AM #8
What does the Main-class: entry in your manifest look like now?
Your earlier post showed it was wrong if your class is in a package.
It must have the package-path with the classname:
Main-class: <package>.<classname>
- 09-26-2008, 12:14 PM #9
Manifest-Version: 1.2
Ant-Version: Apache Ant 1.7.0
Created-By: 1.4 (Sun Microsystems Inc.)
Main-class: TenderManagementSystem.IndexFrame
Class-Path: lib/swingx-0.9.3.jar lib/AbsoluteLayout.jar lib/mysql-connector-java-5.1.6-bin.jar
i extracted the netbeans generated jar and changed the main class entry of the .mf file thn i manually rebuild the jar from the extracted archive...
now the problem is if i manually build the jar, its size reduces and doesn't work , i told u before...and the netbeans generated jar don't have the package name in the manifest main class entry....
is there any other way to build jar other thn this command?
jar cmf manifest.mf jarfile.jar components
- 09-26-2008, 03:38 PM #10
Please post the full text of error messages.doesn't work
Java is case sensitive. In one place you posted:
tendermanagementsystem/IndexFrame.class
then in the manifest you show:
Main-class: TenderManagementSystem.IndexFrame
If they refer to the same class, they MUST be spelled the same way.
Look at the contents of the jar file generated by netbeans and compare that to the one that you generate manually. What files extra files are included in the larger one.
Your jar command syntax looks ok. The thing I can't check is whether the "components" part is write.
I have a program that will look in a jar file and check for some of the errors you are having. Open the jar file, Choose the jarfile, it should load the Class name field if it finds a manifest and press
Search. The program reads the class files in the jar looking for the starting class and for all classes reference by that class:
http://shellknob2007.googlepages.com/CheckClassRefs.jar
- 09-27-2008, 08:15 AM #11
#Searching C:\Documents and Settings\Others\My Documents\NetBeansProjects\TenderManagementSystem\ dist\TenderManagementSystem.jar for IndexFrame
IndexFrame >>>> class NOT found! <<<<
# Found 1 classes. 1 NOT found.
at first its automatically loading IndexFrame in the class field...later its telling that class not found....
and the class its loading has no package informations...
- 09-27-2008, 08:47 AM #12
oohh...finally it worked...here are the steps.
1. Extracted the damaged JAR in a folder named TenderManagementSystem.
It contains 3 folder:
- images (images)
- META-INF (manifest)
- tendermanagementsystem (classes)
2. Added Package Info in the META-INF/MANIFEST.MF file main class entry.
Main-class: <package>.<classname>
3. Cut the MANIFEST.MF file and paste it outside the META-INF folder.
3. Windows -> Run -> cmd
4. cd ExtractedFolder
5. jar cmf MANIFEST.MF TMS.JAR tendermanagementsystem images
it resulted into a TMS.JAR which is working just fine... :D
thanx to Norm...u r a good teacher and u didnt loose your temper when i wasnt successful. i will keep in touch with ya.
thanx again.
- 09-27-2008, 03:21 PM #13
Similar Threads
-
Problem with String Building
By Albert in forum New To JavaReplies: 2Last Post: 04-30-2012, 12:49 AM -
Building projects with the JRE (not the JDK) in Eclipse
By zachwong in forum EclipseReplies: 15Last Post: 09-30-2008, 03:50 AM -
help needed regarding tree building
By invincible_me in forum New To JavaReplies: 2Last Post: 08-12-2008, 01:44 PM -
building a house
By dc2acgsr99 in forum Java AppletsReplies: 4Last Post: 03-07-2008, 11:18 PM -
Building a document from a DOM
By Java Tip in forum Java TipReplies: 0Last Post: 01-03-2008, 09:22 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks