Eclipse + fjep (one-jar) package Java project as a single jar

Source: Internet
Author: User
This article describes how to use the eclipse + fjep plug-in to package a Java project into a single executable jar, so that a single jar can be released even if an additional third-party jar is used.
Fjep: http://fjep.sourceforge.net/
Fjep tutorial (http://fjep.sourceforge.net/fjeptutorial.html) explains how to use fjep to package, fjep's job is to expand the third-party jar, directly put the third-party classes in the form of a folder (Package) into the customer jar
For example, the customer project is fjepdemo (only one Java file: fjepdemo/demo. java), uses a lib (jar) as fjeplib. jar (including: fjeplib/lib. class), the structure of the file packaged with fjep is as follows:

Fjepdemo. Jar
/Fjepdemo/demo. Class
/Fjeplib/lib. Class

Fjeplib. jar is no longer in the form of jar in the newly released jar.

If the third-party jar rule does not allow publishing modification, it cannot be expanded in this way. At this time, one-jar can be used for processing, "The One-jar option integrates a specialised class-loader written by Simon tuffs (http://one-jar.sourceforge.net/) which handles jar-files inside a jar."

One-Jar has been integrated into fjep. The check box one-jar can be checked in the package. fjeplib is hit to fjepdemo. jar/lib/fjeplib. jar.

In addition, if the project uses additional resource files, such as I/O operations, to read and write a TXT file, it cannot be read and written in a common file path. Package fjepdemo;
Import fjeplib. Lib;
Import java. Io .*;
Public class demo ...{

/***//**
* @ Param ARGs
*/
Public static void main (string [] ARGs) throws ioexception ...{
// Todo auto-generated method stub
Lib. Print ();
Inputstream is = demo. Class. getresourceasstream ("/1.txt"); // note the path of the resource file
System. Out. println (is. Available ());
}

}

The structure of the packaged file is as follows:
Fjepdemo. Jar
META-INF
...
/Main
...
/Lib
Fjeplib. Jar
/COM
... // The content of One-jar
1. txt

Run the jar> JAVA-jar fjepdemo. jar on the console.

Refer:
Http://fjep.sourceforge.net/
Http://one-jar.sourceforge.net/
Http://www-128.ibm.com/developerworks/cn/java/j-onejar/

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.