Last
revision of this document: |
This
step of the tutorial
* covers the packing of different packages
into a JAR-file using the 'Packaging Configuration' of Eclipse
and
* and the command-line command to run the application with the
inclusion of JAR-files for DOM and database-access.
Preface:
There
is a functionality in Eclipse to pack a project in a JAR-file which
is shown in Struts lesson 4a: A
Test-Client to test the Session-Bean.
Nevertheless the
'Packaging Configurations' is used in this Tutorial as in the
projects using Struts this knowledge is expanded for packing more
than just JAVA-applications.
Thereafter the
simplified functionality is explained - I hope you understand my
idea.
Credits:
I
took the guideline for packing from the 'JBoss 3.0 Workbook For
Enterpris JavaBeans 3rd Edition' by Bill Burke and Sacha
Labourey.
As the 4th Edition is already available as
hardcover, the book is no longer available for download.
Before
you are going to buy this book: for a beginner, this book is not easy
readable - it is a good textbook if you want to continue after my
tutorials are finished.
JS_Base02f, Step 6 – Print out the report completed – and its prerequisites too.
Pack
into a JAR (JAva-Archive):
Eclipse
has a pretty sophisticated functionality to select files for further
processing (not only packaging) and carry out the processing.
This
functionality is based on the ANT (Another Neat Tool) but has a
pretty easy to operate GUI.
;-) If you wrote
ANT-scripts you will understand what I mean ;-) .
To
start the Packaging by clicking with the right mouse-button onto the
project (JS_Base02) and selecting >Properties.
:
In
the left area select 'Packaging Configurations' and click the button
[ Add... ]
In
the window popping up enter the 'Name:' (js-base02.jar)
and click the button [ OK ]
Now,
the files which should be packed into the JAR-files have to be
selected.
To do so, click with the right mouse button onto the
text ('js_base02.jar) and select >Add Folder...
In
the window popping up click the button [ Project Folder... ]
Select
the folder 'gen/classes' and
click
the button
[
OK ].
Enter
**/*.class in the field 'Includes' and
click
the button [
OK ].
The value
is a little bit
overkill as in this project only (Java-)class-files are located
there.
**/*.class
Also the
would not be necessary as
it means 'include files in sub-folders' which are not present in
this project.
**/
As this step is also a preparation for more complex
tutorials I found it a good idea to introduce a little bit of the
capabilities that Eclipse and ANT offer.
The
future content of the jar-file can be seen by clicking onto the
little triangle left of 'js_base02.jar' (if it is not already
expanded).
C
to close the window and generate the script-file which
controls the packaging-processlick
the button
[ OK ]
.
To
start the packaging process click onto the project 'JS_Base02' suing
the right mouse-button and select >Run Packaging.
The
process can be watched in the 'console' window of Eclipse.
In
this example, the generated JAR-file (with the name 'js_base02.jar')
is stored in the directory
'/home/kurti-o/js_tutorials/JS_Base02'.
The directory depends
on your individual configuration and will - for sure - be different
!
top.
Run
the application outside Eclipse:
For
the 'real-life' a JAVA-application is started by a command issued
over the command-line.
This command also has to include the
libraries (jar-files) with packages that are included in the
developed application.
For this tutorial the following
configuration was valid.
* developed application packed in file
'js_base02.jar' in directory
'/home/kurti-o/js_tutorials/JS_Base02';
*
libraries for the DOM-methods (Document-Object-Model) in file
'jdom.jar'
in directory
'/usr/java/j2sdk1.4.2_08/lib/extern';
* libraries for the access
to the MySQL-database in file 'mysql-connector-java-3.1.12-bin.jar'
in
directory '/usr/java/j2sdk1.4.2_08/lib/extern'
.
For
your configuration please adapt your command !
To
start the application open a 'Terminal'-window and enter the
following
command:
java -cp /home/kurti-o/js_tutorials//JS_Base02/js_base02.jar:/usr/java/j2sdk1.4.2_08/lib/extern/jdom.jar:/use/java/j2sdk1.4.2_08/lib/extern/mysql-connector-java-3.1.12-bin.jar
js_base02.application.JS_DBLoad
The
above classpath-delimiter (:)
between the files is LINUX-specific; for other operating-system it
might be different.
.
.
.The
user-dialog starts.
top.
Next
Step(s):
There
is no direct continuation to this step.
Depending on your
interest you may continue with the following tutorials
Exploring
the Struts framework.
This supports the development of
applications using a Web-Browser as GUI
(Graphic-User-Interface).
Starting point is JS_Struts00 - Import
the Struts framework.
Develop
EJBs (Enterprise Java Beans).
EJB is a technology to support a
client/server-architecture utilizing the capabilities of a
Java-Application-Server (e.g. JBoss):
Tutorial
will be available soon.