aspose file tools*
The moose likes Tomcat and the fly likes my .war with .jars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "my .war with .jars " Watch "my .war with .jars " New topic
Author

my .war with .jars

achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Hi.
Pls assume my html_dir = /var/www/html
I would like to deploy apps by simply dropping an apps.jar into $html_dir.
Then in my <APPLET..>-tag I can specify ARCHIVE=yadda.jar
However the directory structure inside .jar must be maintained because of the "packages" in the java e.g.
package com.developer.Tunnel;
package com.developer.Tunnel.client;
package com.developer.DataSource;
etc
How does one maintain the directory structure when zipping the .class into a .jar ?
Also, what's the diff betw .jar and .war


humanum errare est.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

directory structures are maintained by default when you use the jar command to package up your classes.

assuming your directory is something like:

then the following command from the src directory will produce a properly package jar file.



The only difference between jar and war is the extension. There are no file format differences, I should say - the contents are usually different, and the intended use of each file is different.
[ October 25, 2002: Message edited by: Mike Curwen ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

A WAR is a JAR laid out for the purpose of distributing a webapp. If you design the webapp using Sun's recommended directory structure and including a WEB-INF/web.xml file then when you jar it, you've created a WAR file (you DO have to name it ending with .war as well).
jar is like ZIP - unless you give orders to the contrary, the resulting archive file will map the directory structure of the original files, so a
"java -d abc *.java" if your files are located in the current directory but have package names as listed will produce (assuming directory "abc" exists:

if you were to jar like this:
jar cf myjar.jar abc
You'd build a defective jar, since the "abc" directory level would be included in the jar's directory structure. What would work would be:
cd abc
jar myjar.jar *
But you'd then end up with "myjar.jar" in the abc directory.
Actually, for complex projects it's easier to use Ant, which can be used to compile the java files and create the jars and wars.
Jars WITHIN a WAR are placed in the root of the WAR for jars to be downloaded to the client and in the WEB-INF/lib directory for jars used by the server code. You can place downloadable jars in alternative locations if you set up the proper URLs for the jars.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: my .war with .jars