120 likes | 259 Views
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
E N D
How to Create a Working JAR File in Eclipse Eclipse JAR
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
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
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.
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
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.
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