This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

my .war with .jars

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • 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
  • 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: 22501
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic