Eclipse in jar formation and application package

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.