Recent familiarity with the Java language. Eclipse is often used to familiarize itself with it during the learning process. This article simply describes jar formation and application packages.
Java in the jar is equivalent to the package C + + in the Lib library, it is a. class file packaging, often using the jar package has API library package (^_^, this is my fiction) runnable jar package. This article explains the creation of the API library package. The operation steps are as follows:
Create a new javaprojectjarexp. Create a new Jarexp.java file; The source Jarexp.java to generate the jar package is:
Package Com.lming08.data;import java.io.*;p ublic class Jarexp {public void print () {System.out.println ("class Jarexp Executed! ");}}
The process for generating a Jar package is: Right-jarexpproject--->export---->jar File---->next----->finish
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbg1pbmdfmdg=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "align=" Middle ">
This generates a JAR package.
--------------------------------------------------------------------------------------------------------------- ----
The above is the process of generating a jarexp.jar package, and the following explains how to reference the package in other project.
Create a new jarimpproject, and then create a new Jarimp.java file with the following file contents:
Package Com.lming08.data;import Java.io.*;import Com.lming08.data.jarexp;public class Jarimp {public static void main ( String[] args) throws exception{jarexp je = new Jarexp (); Je.print ();}}
Right-click jarimpproject---->build Path----->configure Build Path
There are two options, the first of which is to choose Add Jars, which is to refer to the corresponding Jar package in project in Eclipse, and the other is to choose Add External Jars. It means that the jar package can be referenced in whatever folder. In this article, you select the first, so now create a new Lib folder in Jarimpproject and copy the Jarexp\lib\jarexp.lib to Jarimp\lib\, then click the Add Jars option to select Jarimp\lib\ Jarexp.lib. This will enable the execution of the jarimpproject, and the resulting result will be:
Class Jarexp executed!
It is clear that the result is correct, the new generation proves that the jar package and the reference jar package are successful.
Eclipse in jar formation and application package