1 / 11

How to Create a Working JAR File in Eclipse

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

arden-young
Télécharger la présentation

How to Create a Working JAR File in Eclipse

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to Create a Working JAR File in Eclipse Eclipse JAR

  2. 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

  3. Eclipse JAR

  4. 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

  5. Eclipse JAR

  6. 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.

  7. 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

  8. Eclipse JAR

  9. 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.

  10. Eclipse JAR

  11. 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 CCddccCC processing input CCddccCC: GG22qiHF

More Related