How do you jar your files?

E

Elliot W. Scott

Hey there, I am an ex-.NET programmer, and I just have a detailed a
question for all of you. I don't understand how the jar utility is
supposed to work. Lets say I have this folder structure in my HD.

C:\
|-projects
| |-projecta
| |-com
| |-foo
| |-bar
| |-TestApplication.class
| |-TestApplication.java
| |-AnotherApplication.class
| |-AnotherApplication.java
|
|-misc
| |-org
| |-somewhere
| |-example
| |-Ancillary.java
| |-Ancillary.class


In my jar file. I want the following contained as such

|-com
| |-foo
| |=bar
| |-TestApplication.class
| |-AnotherApplication.class
|-org
| |-somewhere
| |-example
| |-Ancillary.class

How would you use the jar utility to create this jar file. I know about
ant and that works great. I just want to know how to efficiently and
quickly do this using the jar utility. I have a solution, but it seems
contrived.
 
J

John McGrath

How would you use the jar utility to create this jar file. I know about
ant and that works great. I just want to know how to efficiently and
quickly do this using the jar utility. I have a solution, but it seems
contrived.

Use the jar -C option to specify the root directory. For example:

jar cf file.jar
-C C:/projects/projecta
com/foo/bar/TestApplication.class
com/foo/bar/AnotherApplication.class
-C C:/misc
org/somewhere/example/Ancillary.class

Of course, all of the above would go on the same command line. If it gets
too long you can write the options & files to a file and use the "@" sign
to include it in the command. See the JAR docs in the JDK for more info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top