how to create a working jar file in eclipse

11
Eclipse JAR How to Create a Working JAR File in Eclipse

Upload: arden-young

Post on 01-Jan-2016

26 views

Category:

Documents


1 download

DESCRIPTION

How to Create a Working JAR File in Eclipse. Create Your Project. Create an Eclipse project with a separate bin directory for class files Create a new folder called lib - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: How to Create a Working JAR File in Eclipse

Eclipse JAR

How to Create a Working JAR File in Eclipse

Page 2: How to Create a Working JAR File in Eclipse

Eclipse JAR

Create Your Project Create an Eclipse project with a separate bin directory for class

files

Create a new folder called lib

From the command line, place the jar file you want to add as a library inside the lib folder and extract the contents of the file

Create the .java files that are your program.

Create a MANIFEST.MF file in the project directory.

See the next slide for this state of affairs.

[pletcha@archimedes lib]$ pwd/home/pletcha/workspace/GetOpt2/lib[pletcha@archimedes lib]$ jar -xf commons-cli-1.2.jar

Page 3: How to Create a Working JAR File in Eclipse

Eclipse JAR

Page 4: How to Create a Working JAR File in Eclipse

Eclipse JAR

Add to library

Right click on the lib directory and select

See the next slide

Build Path/Configure Build Path/(Libraries Tab)/Add Class Folder

Page 5: How to Create a Working JAR File in Eclipse

Eclipse JAR

Page 6: How to Create a Working JAR File in Eclipse

Eclipse JAR

Make Sure Your Program Runs

Test your program in the Eclipse environment. It should find all the classes it needs, including the apache-commons-cli classes.

Page 7: How to Create a Working JAR File in Eclipse

Eclipse JAR

Create the JAR File

Right Click on the Project name in the Package Explorer and select:

In the JAR File Specification dialog

select as resources to export .classpath, .project and MANIFEST.MF.

Also export the source files, specify the destination for the JAR file and finally click Next. (See next slide.)

Export/JAR File/Next

Page 8: How to Create a Working JAR File in Eclipse

Eclipse JAR

Page 9: How to Create a Working JAR File in Eclipse

Eclipse JAR

Keep Going

Skip the Packaging Options dialog (click Next) and in the JAR Manifest Specification dialog specify that you will use a pre-existing MANIFEST.MF file (the one you created).

Click Finish.

See next slide.

Page 10: How to Create a Working JAR File in Eclipse

Eclipse JAR

Page 11: How to Create a Working JAR File in Eclipse

Eclipse JAR

Test Your JAR File

Go to the directory where you placed the jar file and execute

Send the JAR file to me in an email.

[pletcha@archimedes temp]$ java -jar GetOpt.jar -s CCddccCCprocessing inputCCddccCC: GG22qiHF