Here are the steps:
First, it puts its own publishing program into jar file
This is the eclipse comes with features, right-engineering package -> Export
Then select Java -> JAR file, next
Selected output path, next
Uncheck the Export class files with compile errors, because the general warnings can be ignored, and errors will not do, next
Selected main class, i.e. the class with the main method, finish can.
Second, the jar files into exe files
jar file ready to run. But you need to send someone else to run into exe files needed
There are many ways, I use the exe4j this software, I feel pretty good
Download is easy to find, not to mention here
After installing the software is opened, there are ten steps
Ten steps before. You need to create your own folder name at random, to save environmental resources file conversion needed
Inside the file you need to have the folder jdk jre and lib two folders can be copied
There are previously generated jar file, the following is to create a good directory structure
Then look at software
1.welcome
Here, if the first time does not require the tube, next
If you are finished using the saved output configuration, you can select open configuration
There is also a registered yet: http: //blog.sina.com.cn/s/blog_002e20310101bt9y.html
2.Project type
Select "JRA IN EXE" mode, next
3.Application info
Fill the box above program name
The following output path selection block
4.Configure executable
GUI application -> tick allow ..
Fill in the box below the name of the file
you can choose your own icon file icon file (presentation site: http://www.favicon-icon-generator.com/favicon )
If the limit can only open one program at the same time, check allow only a single ...
Other basic default.
如果你的exe4j和jdk位数不一致,记得把advanced options里的32bit or 64bit勾选
否则生成不报错exe也无法正确运行
5.Java invocation
点Class path框右边的绿色加号
把自己生成的jar文件路径写进Archive
(用到的外部jar包也要都添加进去)
然后下面main class from框选择含有main方法的类
6.JRE
Minimum和Maximum填写允许的最小和最大jdk版本号
Configure search sequence选项
框里应该只保留Search Windows registry,没有的话右边绿色箭头添加
其他的删除后,绿色箭头添加Directory,找到我们开始的时候拷到文件夹里的jre
perferred VM选择默认即可
7-10基本无脑next即可
可以保存自己本次的配置以便以后使用
第一次用过之后出现的问题比较少,基本没有报错
但位数问题导致exe打开失败。所以前面也提及了,但我jdk和exe4j都用的64位,系统也是64位
具体原因还有待研究
原文链接:https://blog.csdn.net/qq_28718481/article/details/78848191