Use eclipse to create executable jar files

Source: Internet
Author: User

1. Right-clickEclipseProject, click Export.

2. Select the Java-JAR file.

3. Select the project to be published as a jar file.

1) Select the source folder, library folder, and configuration file folder.

2) do not selectEclipseProject files and other unnecessary files.

3) Select: export all output folders for checked Projects

Output all selected folders.

4) Select: Export Java source files and resources

If the source folder is used, the generated. Class file is output.

5) Select: compress the contents of the JAR file. Comoress the contents of the JAR File

6) Select the destination of an output JAR file.

4. Use an existing manifest file.

5. The manifest. MF file is as follows:

 

IfEclipseThe class-path description is not generated for us. Therefore, we need to add the class-path description!

Manifest-version: 1.0

Main-class: Test

Class-path: lib/oxmled1.11-nolib-bin.jar lib/dom4j-1.6.1.jar lib/commons-logging-1.0.4.jar lib/log4j-1.2.8.jar

6. Select mainclass and select the mainclass to be used from the pop-up dialog box of browser.

 

6. Now, the JAR file is executable.

Run Java-jar AAA. jar in the command line to check that the program has been successfully executed.

Java w-jar AAA. jar can also execute this jar package.

 

The command line window appears when you use java.exe.

Run javaw.exe without the command line window. All output such as system. Out. Print is invisible.

7. If you have installed JRE, your jar file should be associated with javaw-jar.

If your jar file is not associated with Java w-jar, you can re-associate it using the following methods.

1) in the resource window-tools-Folder Options-file type, create a jar Association.

2) create a. BAT file. The command is javaw-jar % 1 or Java-jar % 1.

3) associate the. jar file with the. BAT file above.

In this way, when you double-click the. jar file, the Java program will be executed immediately.

 

% 1 indicates the first parameter, that is, the full name of the JAR file you clicked.

 

8. You can also create a. BAT file for each executable JAR file. The command is javaw-jar AAA. jar or Java-jar AAA. jar.

In this way, you can execute the JAR file without associating the JAR file.

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.