The following WAR file can be used to install the
WebBooks application
(see Java Web Books) into Eclipse. Click
to download:
Assuming that you have done the basic setup work described
in Java Web Projects in Eclipse,
open Eclipse and install WebBooks as follows:
- Right-click on the Projects window and select
Import
WAR file.
- Click the Browse button,
navigate to the location of
WebBooks.war, select it, OK, then Finish.
At this point, I cannot seem to find the exact right method
to run the application without errors, but it combines
these actions, which, if done repeatedly back and forth
will eventually run the application:
- From the Servers tab, Start or Restart the tomcat server.
- Select the WebBooks in Projects, click
the Green Run button and select Run on Server.
Once you get it running, it's important to inspect the contents
of the application to see the parts:
What is the WAR file?
A WAR file is nothing mysterious, it is simply a JAR file
(which is a ZIP file)
with web-related information.
One can "see" what's contained within using
either the Java jar utility
or the unzip utility:
$ jar tf WebBooks.war (change "tf" to "xf" to extract)
or
$ unzip -t WebBooks.war (take away the "-t" to extract)
Adding further JAR files to an Eclipse project
There are probably several ways to make JAR files available
to an Eclipse project,
but the simplest is to add them directly into the folder:
WebContent/WEB-INF/lib
Do so as follows:
- Right-click on this folder in Projects
and select Import.
- In the Choose import source window, select
General File System.
- In the File system window,
Browse to the folder containing
(some of) the Jars you want to add.
They look grayed-out, but don't worry. Click OK.
- Now you should see a listing of the JAR files in
the right-hand side and the folder on the left. Click
the individual choices or the entire folder. Then
click Finish.
The NetBeans equivalent
NetBeans makes it rather easy to add JAR functionality through
its Library mechanism. An equivalent approach would be to
copy these libraries to your Java library directory and
add these as individual JAR files to your project.
© Robert M. Kline