Background: Recently, an old friend who was a teacher asked me to write a small program for her. The program is very easy to implement, but I have never played the .exe application. I searched the Internet and there are several tools that can be packaged. The package was successfully packaged and used. There was an episode of system incompatibility during the period. Finally, it was replaced with 32-bit. It can run on both 32-bit and 64-bit systems. Be sure to use the created jre directory environment for packaging, because the jdk environment will not be installed on a non-developer computer.
working environment
系统:win10 64位
JDK:jdk1.8 64位
开发工具:myeclipse2015
打包工具:exe4j_windows-x64_5_1 下载地址:http://www.ej-technologies.com/download/exe4j/files.html
The program is packaged into .jar
1. Open myeclipse, select the program you want to package, right-click and select export
Click next
Click next
Click next
Select the main category
Click ok and
click finish, the sas.jar file will appear on the desktop
Fourth, convert jar into exe.
Create a new folder, the role of the folder is to save the generated exe file directory, in the newly created folder also create three subfolders file, res, jre
file:文件夹是放临时文件的可以没有
res:文件夹是放资源文件的,如图片,配置文件等也可以没有
jre:这个是必须的,该文件中的内容可以直接把JDK安装目录下jre的内容拷贝过来即可。有了它可以不用再装java运行环境
上面提到我的运行环境是jdk64位,但是在这里面应该放上 jdk32位,即jdk32安装目录下的 jre文件内容,嗯,还有就是如果程序中有任何jar包应该放在SAS\jre\lib\ext文件里。
将exej4下载到电脑上 如果运行界面没有出现 就在安装目录下 bin 目录中点击 exe4j
The following page appears, you can start to convert exe
Click next to select "JAR in EXE" mode
Define casually in Short name of your application
The output directory is used to specify the directory where the exe file is generated, just select the file directory we just created.
Click next
Enter the name of the exe file to be generated in the Executive name
Select Icon File to select the icon to generate the exe file, the icon type can only be a picture at the end of ico
Click next
Enter in VM Parameters: -Dexe.path=${EXE4J_EXEDIR}
Click Add to add the jar file we generated in Archive, and then click the OK button directly
After clicking ok, choose where the main class is the Main class. . . .
Then click ok, then click next
After clicking Search sequence
Delete the original default and add the jre under our newly created folder. Note: The content in the jre is preferably the jre content in the 32-bit jdk. As mentioned earlier, if there is a jar package, you need to It imports.
Click next
Click next
Click next
Click to see if your exe can run.
Then close it.