This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to jar a package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to jar a package" Watch "How to jar a package" New topic
Author

How to jar a package

Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
I need to jar a package application
Here is what I have:
1) directory structure of c:\dmsi\campaignbuilder\<here are the class files>
2) my package name is: dmsi.campaignbuilder
3) I have subdirectories of: c:\dmsi\campaignbuilder\images\<image files are here>
4) I have created a text file name startclass.txt with the following: Main-Class: CampaignBuilder
How do I create the jar for this application, from which directory do I create it, and how do I run it.
Any help would be great.
thanks,
Dean
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

First you need to change 'startclass.txt' to:

and then run this command from C:\

You can now run it by typing: 'java -jar dmsi.jar' or if you are running Win32 just double clik on it.
Rene


Regards, Rene Larsen
Dropbox Invite
Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
I still get an error trying to run it. I get "Exception in thread "Main" java.lang.ClassFormatError: dmsi/campaignbuilder/CampaignBuilder$1 (Bad magic number)............and whole bunch of classloader errors. Any ideas, what I might have done wrong?
Thanks,
Dean
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

How are you running it without the jar file?
/Rene
Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
I run it by having all of the compile class files in the following directory: C:\dmsi\campaignbuilder\
The exact command I use in for c:\
I type c:\jdk1.3.1_02\bin\java dmsi.campaignbuilder.CampaignBuilder
To run the jar file, I have been typing
c:\jdk1.3.1_02\bin\java -jar dmsi.jar
The jar file exists and looks good, I am running it from the c:
Any ideas.
Thanks,
Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
ok, I did the above and got rid of the magic number error, I had muliple jar files.
Now I am getting the error:
java.lang.NoClassDefFoundError: dmsi.campaignbuilder.CampaignBuilder
Any ideas anyone?
Thanks,
Dean
Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
I finally got it to work!!
Here is what I used: http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html
c:\jdk1.3.1_02\bin\jar cmf startclass.txt dmsi.jar dmsi
c:\jdk1.3.1_02\bin\java -jar dmsi.jar
thanks everyone.
Dean
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to jar a package
 
Similar Threads
Problem with packaging using ant
urgent help please (creating jar file using ant)
Unable to create a bean for class myclass?
package javax.ejb does not exist
jar packaging