• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

my .war with .jars

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
My cellmate was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic