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 Developer Certification (SCJD/OCMJD) and the fly likes How to Jar? 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 » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to Jar?" Watch "How to Jar?" New topic
Author

How to Jar?

Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
Hello Everybody:
I am planning to have three jar files for submission. They will be scjd.jar, client.jar, and server.jar. Under scjd.jar I am thinking to have README, docs, all.policy, db.db, client.jar, and server.jar files.
My client.jar and server.jar will be excutable jar files. I am kind of confused here. Each excutable jar file needs an entry point MANIFEST.MF right! I need two MANIFEST.MF files one for client and one for server. How can I have two MANIFEST.MF file with the same name at same place. How you guys have done it? By the way I am writting first MANIFEST.MF file by myself then only I am using jar command as below.
jar cvfm client.jar MANIFEST.MF suncertify\client\*.class
Any response in this regards highly appriciated. Thanks in advance for response. Have a great day everybody. -Bal
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6


I had created a directory structure as follows
c:\devexam
main directory which is the base
in ther I had
c:\devexam\suncertify\client
c:\devexam\suncertify\db
c:\devexam\suncertify\help
for my package directories.
then I had a
c:\devexam\manifest\client
c:\devexam\manifest\server
in each of those I had a separate manifest file.
So when I jarred the files I used the following batch file.

It put some files in the client that the client didn't need, so I would opent he jar file in Winzip and remove those server files not needed.
Hope that helps
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
Hey Mark your batch file is cool. I liked it. Just for curiosity. Did you include this batch file in your submission? I think you did not right! You made your own small tool to produce jar files right.
Thank you. -Bal
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

No, I did not include it in the submission. I had actually made a bunch of batch files to save me time. Especially when I was javadocing. I would make spelling errors, forget something, blah, blah, blah, and have to recreate the javadocs. even though this batch had only one line in it. I had one for running RMIC for creating my Stubs, and one for running the server and client in remote and local modes.
But I made sure none of them were in my submission, because I could not guarantee that the accessor had a windows machine.
Mark
Andre Mermegas
Ranch Hand

Joined: Jun 20, 2001
Posts: 158
or you could use Ant tasks, which is what i did to take care of all the building and stuff for you.
heres my build.xml


--=( Andre Mermegas )=--
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

So then how do you use the build.xml?
It looks pretty cool.
Mark
Andre Mermegas
Ranch Hand

Joined: Jun 20, 2001
Posts: 158
Hey Mark, check it out, its from Apache jakarta project, its called Ant, its kinda like Make for Java.

Ant Page
Johnny O'Boylan
Greenhorn

Joined: Feb 07, 2002
Posts: 21
I have to agree! Ant is an excellent tool which is great to utilize. You will be hearing alot about it soon. I have even saw "Ant" as a desired skill in some Java Job descriptions.


==================================<br />If you choose not to decide,<br />you still have made a choice.<br />==================================
Reshma Das
Ranch Hand

Joined: Jan 29, 2002
Posts: 125
why do we need ant for this project. the examineer is not going to build the project. it is for own personal purpose. a normal batch file would help.
ant is useful for deploying ejb's.
Steve Granton
Ranch Hand

Joined: Jan 13, 2002
Posts: 200
Hi,
I've got to agree. Ant is the Dogs Bo**ocks when it comes to build and deployment for Java.
I'm also using it for the SCJD project. I've got tasks, amongst others, to create the javadocs and run junit tests. One thing I like is that it can produce the report from the junit tests as XML which it can run through a stylesheet for you! I think there is also a task to make you a cup of coffee :-)
There are tasks for just about anything you could imagine - and if there isn't a task you can write your own!
Certainly something for your CV.
Cheers,
Steve
Steve Granton
Ranch Hand

Joined: Jan 13, 2002
Posts: 200
Hi,
Its a personal choice of course. I'm only using Ant for build and deployment as I'm familiar with it, its easy to use, has a lot of nice features, and it means I don't have to try and hack around with a half baked batch language to build and deploy. Maybe I'm just allergic to goto statements!!! :-)
However, for anyone who is about to start the project or has just started then its probably worth investing some time in Ant as its growing in popularity - I wouldn't like to have to build and deploy an enterprise application with platform specific batch files!
Cheers,
Steve
tom mcmorrow
Ranch Hand

Joined: Jan 11, 2002
Posts: 39
Hi
i have looked briefly into ant it seems interesting. However i wonder if it is nesessary to be proficient at xml to utilize it.
also any other good sites giving an introduction to it for a beginner.
tom mcmorrow
Steve Granton
Ranch Hand

Joined: Jan 13, 2002
Posts: 200
Hi,
I don't think its really necessary to know too much about XML. As long as you know attributes, elements and that a start tag must have a corresponding end tag. The Ant dtd can be used to validate your build.xml and in fact it probably does validation when you call a task.
Its really straight forward and easy to use - all the tasks (built-in and optional) are in the docs. Its really intuitive - for instance:
<mkdir dir="c:\mydir" />
will create a new directory and
<echo>This is a message</echo>
will echo a message when you call the task.
I don't know of any other sites for Ant but I've never needed one - all the information, including tutorials, is on the Ant site.
I hope this helps,
Cheers,
Steve
tom mcmorrow
Ranch Hand

Joined: Jan 11, 2002
Posts: 39
hi Steve
Do i need to install a xml parser to use ant or is it part of the ant download. I see file crimson.jar is this sufficient on my Classpath or do i need say Sun's parser.
Thanks in advance
tom
Steve Granton
Ranch Hand

Joined: Jan 13, 2002
Posts: 200
Hi,
You just need to download Ant. The download comes with the Apache Crimson XML Parser - though you can change it for another JAXP compliant parser but I've never needed to. The only other thing you need is a JDK on your system. You then set the ANT_HOME environment variable and off you go!
Cheers,
Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Jar?
 
Similar Threads
A JAR PROBLEM
Pass with 149/155
packaging runme.jar
Where does the LockManager class lie ? db.jar or Server.jar ?
is it necessary