This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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 ]
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.
An IDE is no substitute for an Intelligent Developer.