jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Diff. Btwn EAR, WAR, & JAR Files???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Diff. Btwn EAR, WAR, & JAR Files????" Watch "Diff. Btwn EAR, WAR, & JAR Files????" New topic

Diff. Btwn EAR, WAR, & JAR Files????

Elle Atechsy
Ranch Hand

Joined: Jan 23, 2004
Posts: 96
Hi All,

I'm a little confused on where EAR, WAR, & JAR files can run. I'm working on an application in which an application server farm group requires us to package our service in an EAR file. That's fine. But now I would like to ask about what is the best way to package our client packages. For one pacakage the client will only make event calls, so there will not be any java processes continuously running. For the other, we need java processes to run to continuously listen to a queue. There are no web requirements. The trick is that we cannot guarentee that all of our clients will be using application servers. Therefore, we need to package it in a way so that it will just run on a JVM. Can the JVM run EAR and WAR files? Or, do we have to have 2 different package options to accomodate client setups?

Thanks in advance for any assistance.

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

EAR, WAR, and JAR files are all PKZIP-format files containing a META-INF directory with a MANIFEST.MF file in it. Beyond that, EAR and WAR files have some additional requirements. WAR files contain a WEB-INF directory with a web.xml file in it; I can't tell you off the top of my head what's in an EAR file, but it's something similar.

Anyway, a runnable JAR file has a special entry "Main-Class" in the MANIFEST.MF file that tells how to run the file. If you put such an entry in a WAR or EAR file's manifest, the command-line "java.exe" will be able to run it -- the name doesn't matter. So I believe that this is possible.

[Jess in Action][AskingGoodQuestions]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

EAR (Enterprise Application Archive) and WAR (Web Application Archive) files are special kinds of JAR files.

You need a J2EE application server to run EAR files.
You need a servlet container or J2EE app server to run WAR files.

Which kind you should use depends on your application. If it's a J2EE application with EJBs (Enterprise Java Beans), you need to build an EAR file and deploy it in your app server. If it's a web application with servlets and JSPs but without EJBs, you can build a WAR file and deploy it in the servlet container.

A plain JVM cannot run EAR and WAR files.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link: http://aspose.com/file-tools
subject: Diff. Btwn EAR, WAR, & JAR Files????
It's not a secret anymore!