Questions and ideas
People may encounter this situation, their hard-working Java program, but on someone else's computer can not run, there may be several reasons for this:
- Your own programs rely on external jar packages
- The picture cannot be displayed after the program has been shot into a jar package
- The other computer does not have a Java environment
But isn't Java a good portability? Is there a way to do a Java program that can be executed everywhere? There are various methods on the Internet, but they are relatively general, or can not be used in some cases, here is a practical experience of my own as an example for everyone to reference.
The core ideas are as follows:
- Make your own program into a jar package
- Turn the jar package into an EXE file while establishing a jar package dependency, and a relative link to the JRE environment
- Create the Installer
Required Software:
- Of course eclipse is essential (or myeclipse)
- EXE4J (turn jar into exe) Download: http://www.onlinedown.net/soft/15755.htm
- Inno Setup (build installer) Download: Http://rj.baidu.com/soft/detail/15918.html?ald
Detailed steps
1. Export JAR Package
2. Generate EXE executable file
First, install exe4j This software, process, do not say, all the way next on the line, open after the following interface:
2.0) Here requires license, if not, it is possible, but each time you run your program will pop-up window, so you can search the Web license.
(Transfer here on the blog provided, http://wangyali90516.blog.163.com/blog/static/117205101201232641920294/)
2.1) Left Select "Project type", there is "Regular mode" and "Jar in EXE", the difference is that you introduce the jar package in the program, should not be packaged together into EXE, in fact, I choose the first kind of it. Click "Next".
2.2) The following interface appears
The application name, the package exe file directory, the directory where your jar file is located, respectively. After completing, click "Next".
2.3) The following interface appears
Select GUI application and fill in EXE file name, icon (optional).
2.4) Add your jar package, and the jar package that you introduced to the program, and fill in the entry for your program below and click "Next".
2.5) When you are finished, fill in the scope of your desired Java environment, select Advanced Options, and then select Search sequence:
Delete the default 3, and then select the JRE folder in your installation file:
The rest is almost the default.
Java packaged as EXE and portable