Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse exporting JAR in WAR

Tags:

java

eclipse

I have two projects in eclipse, a library project producing a Jar file and a web project dependant on that Jar. How do I get the web project to export the first projects jar in its war automatically. I know this must have been answered before, but I really cant find it.

Thanks,

like image 241
aronp Avatar asked Jan 07 '11 23:01

aronp


People also ask

Is a WAR file a jar file?

The WAR file is simply a JAR file (which is itself a fancy ZIP file) with specified directories for the Java code and one designated configuration file: the web. xml file, which tells the application server what to run and how to run it.


1 Answers

The mechanism to determine what goes in the war is not the build path as for "normal" applications, but the "Deployment assembly".

Right-click on the root node of the dynamic web project, and select Properties, and select Deployment assembly. Here you can add projects (which are jarred up and added to WEB-INF/lib) and individual jars in the project.


EDIT 2015-08-20: A few years later, Maven has become the standard way to build Java-based software primarily due to the script based approach to dependency management. This includes how to build WAR-files, and the three major IDE's (IntelliJ, Netbeans and Eclipse) fully support this allowing you to switch between IDE's while developing. In Eclipse the problem asked here will not apply, as this is fully controlled by the Maven plugin.

like image 72
Thorbjørn Ravn Andersen Avatar answered Nov 08 '22 09:11

Thorbjørn Ravn Andersen