How to use fat jar to create a jar package in eclipse

Source: Internet
Author: User

Fat jar Eclipse plug-in User Guide

Fat jar Eclipse plug-in:
Http://downloads.sourceforge.net/fjep/net.sf.fjep.fatjar_0.0.25.zip? Modtime = 1168127388 & big_mirror = 0

Installation:
SeeHttp://sapo2000.blog.163.com/blog/static/8832609200610724746676

Application:

Step 1:Create a Java Project
A. Create a Java project "demolib"
B. Add the package "demolib"
C. Add the class "demolib. Java ",CodeAs follows:

Package demolib;

Public class demolib {
Public static void sayhello (){
System. Out. println ("hello ");
}
}

Step 2: Use the fat jar plug-in to generate a jar package
In package explorer, right-click the project "demolib" and select "+ build fat jar" Appears: "Demolib_fat.jar" is created under the root directory of the project.Click "Next" to select the. Class file to be included in the jar file. Step 3: Create a Java Project
A. Create a Java project "demorun"
B. Right-click the project and choose Properties> JAVA build path> library> Add jar package "demolib/demolib_fat.jar" Step 4: Create main class
A. Add the package "demorun"
B. Add the class "demorun. demorunmain. Java"

Package demorun;

Import demolib. demolib;

Public class demorunmain {
Public static void main (string [] ARGs ){
Demolib. sayhello ();
}
}

Step 5: Create a fat jar dialog
file-> export, and then select" + Fat jar exporter ". The following message is displayed: next select project: next Select Main class: finished! the file "demorun_fat.jar" has been generated under the project root directory and is used to save the configuration ". files ending with fatjar are also generated in the project root directory. The generated JAR file contains all the classes referenced by the jar package (demolib_fat.jar) and its own engineering class. This file can be executed anywhere without setting the classpath variable, because all necessary class libraries are extracted to "Fat jar.

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.