Export the JAR file from myeclipse and replace it with the EXE executable file.

Source: Internet
Author: User


This article contributed by wo940080073

1. Export the JAR file:

If your program development is nearing completion and you are preparing to generate a desktop executable file but do not know how to operate it, follow these steps: select your project --- Right-click the pop-up Option List --- Select export --- Java --- JAR file --- next --- browser (select the jar storage path) --- next (continue the Next Step no matter how many) ---Browser (select the main class of your program-- OK) --- finish; check whether the jar directory is generated? If not, you must not follow the steps.
Ii. Run the JAR file:
You can double-click the generated JAR file to run it, but it will be opened as a compressed package by default. If this is not the result you want, right-click the file --- open method --- Select Java (TM) platform to run. I think you should see your software interface. congratulations ..
3. export to the JAR file together with a third-party file:
If you use APIs or other ancillary resources provided by a third party during program development, you must export third-party files when exporting and generating jar files, otherwise, your program running will not reach the desired result.
You can use the fat jar plug-in to generate jar, fat jar: http://sourceforge.net/projects/fjep/ file is net.sf.fjep.fatjar_0.0.31.zip, after decompression you will see the net. SF. fjep. fatjar_0.0.31.jar file in the plugins folder (fat jar ).
Plug-in installation: copy the fat JAR file to the Plugins under your eclipse directory .. restart your eclipse platform and check window --- preferences. If the pop-up window contains fat jar preferences, it indicates that you have installed the program successfully. If this item is not installed successfully, perform the following steps: Go to configuration --- org under your eclipse directory. eclipse. update and delete platform. XML file, and then restart eclipse. view window --- preferences and you will find Fat
Jar preferences. Congratulations, you have installed it successfully. (if not, you can directly hit the wall )..
Package with fat jar: Right-click your project and select build fat jar from the options list. The pop-up window is very friendly and easy to use at a glance, click browser (main-class select your main class) --- next --- finish (check the resources you need to package together, and select all by default ). the jar file is generated in your project. run it, and everything goes smoothly. Otherwise it will be your programming problem ..
In addition, if you do not want to use fat jar for packaging, there is a quicker method to help you, but it is also flawed.
Step: place the necessary ancillary files in the \ Lib \ ext directory under your JRE installation directory (JRE is also installed when JDK is installed ), then generate a jar file by using (1. Export the JAR file. in this way, you can. it has a fatal drawback: Such jar files can only be used on your local machine. To run on another machine, you must place the same ancillary resources in \ Lib \ Ext.
4. Convert the JAR file into an EXE executable file:
EXE files are easy to use and can improve the security of source code and resources, but it also loses the original intention of Java-cross-platform.
If you insist on converting to an EXE file, follow these steps:
Use the exe4j software to convert the JAR file to the EXE file, exe4j: http://www.ej-technologies.com/download/exe4j/files.html, (the latest version is 4.2) some need to install, some just extract can be used. I usually use the installed exe4j software. There is no difference between them, so just find a usable one. after the installation is downloaded, run it and perform the following operations:
1. Click Next after running.
2. Select the second item "jar in EXE mode" and click Next.
3. In the general --- short name of your application box, enter the name of your application (whatever you want), enter the Save path of the generated EXE in the directories --- output directory box, and next.
4. enter the name of the EXE to be generated in the excutable Name box. "icon file" is a small icon displayed by the application. Do not select it. Continue to next.
5. You must first configure the class-path and click + to add the file, that is, the JAR file. If it is useful to other resources, you need to add the resources together.
6. General --- main class: select the main class.
7. Java version --- Minimum Version (earlier versions must be filled in), maximum version (later versions can be blank), if all are filled in, the value of the later version must be greater than the value of the lower version.
8. check allow jres with a beta version number and only allow jdks and no jres. next. in this step, you can directly finish. in this way, the JAR file is converted into an EXE file. click here to start the application to test the generated file.
This is the end. Does it help you? I want to solve some of my troubles ..

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.