前置准备:
1、一个java可执行jar包;
2、exe4j(java exe制作工具);
3、Inno Setup(将依赖打包进exe文件);
一:用exe4j打包exe文件
打开exe4j,输入注册码(可以不输,但是最终运行exe文件会提示:this executable was created with an evaluation version of exe4j),name和company可以随便输,注册码从下面随便选一个:
A-XVK258563F-1p4lv7mg7sav
A-XVK209982F-1y0i3h4ywx2h1
A-XVK267351F-dpurrhnyarva
A-XVK204432F-1kkoilo1jy2h3r
A-XVK246130F-1l7msieqiwqnq
A-XVK249554F-pllh351kcke50
A-XVK238729F-25yn13iea25i
A-XVK222711F-134h5ta8yxbm0
A-XVK275016F-15wjjcbn4tpj
A-XVK275016F-15wjjcbn4tpj
![](https://img.haomeiwen.com/i10074549/c714d1a50167f19e.png)
![](https://img.haomeiwen.com/i10074549/53ff10790988ceb5.png)
![](https://img.haomeiwen.com/i10074549/baa6d09abd55ee09.png)
![](https://img.haomeiwen.com/i10074549/6fefa6783e88e31d.png)
![](https://img.haomeiwen.com/i10074549/58de4389cddb8e8a.png)
![](https://img.haomeiwen.com/i10074549/d25cc85850ac4b98.png)
![](https://img.haomeiwen.com/i10074549/df9ba899f67e7218.png)
![](https://img.haomeiwen.com/i10074549/ff6891ec552e0b9c.png)
在VM参数配置的地方加上:-Dfile.encoding=utf-8
![](https://img.haomeiwen.com/i10074549/75add9c2291cfc8a.png)
![](https://img.haomeiwen.com/i10074549/d9680f1c4953049f.png)
![](https://img.haomeiwen.com/i10074549/12c946f928dbdb72.png)
![](https://img.haomeiwen.com/i10074549/515a590dd88f2098.png)
![](https://img.haomeiwen.com/i10074549/71c7360aa1adbb04.png)
![](https://img.haomeiwen.com/i10074549/423414c4b930628a.png)
![](https://img.haomeiwen.com/i10074549/8e227b163525637f.png)
![](https://img.haomeiwen.com/i10074549/4760cba9c48067ee.png)
![](https://img.haomeiwen.com/i10074549/fc7356ee0794bdb7.png)
![](https://img.haomeiwen.com/i10074549/22f15699fd598d5b.png)
一直点击NEXT,直到出现以下页面,这时已经在最开始选的路径下生成了exe文件,但是先别打开,需要将这个exe文件和jre合并打包,达到在没有jre环境的情况下也能运行。
![](https://img.haomeiwen.com/i10074549/5fd9dda0c9bccd96.png)
二:用Inno Setup将exe文件和jre合并打包
![](https://img.haomeiwen.com/i10074549/abbffab8d5827f4a.png)
![](https://img.haomeiwen.com/i10074549/e06627ba9bbd7601.png)
![](https://img.haomeiwen.com/i10074549/f0547250b36c1852.png)
![](https://img.haomeiwen.com/i10074549/09b80743cead31f5.png)
![](https://img.haomeiwen.com/i10074549/23e72ca2d816779a.png)
![](https://img.haomeiwen.com/i10074549/12dfbc74c1b0430b.png)
![](https://img.haomeiwen.com/i10074549/7a46713fdcaa9fc8.png)
![](https://img.haomeiwen.com/i10074549/7defdb90eef3c467.png)
![](https://img.haomeiwen.com/i10074549/c61cf3298f51e29c.png)
![](https://img.haomeiwen.com/i10074549/880a76bfada1762e.png)
![](https://img.haomeiwen.com/i10074549/803f41783daf67af.png)
![](https://img.haomeiwen.com/i10074549/16ab195ad1f9eab8.png)
![](https://img.haomeiwen.com/i10074549/82da2f4bc5c7c485.png)
到这里会弹出问你是否马上编译,选择否,先把脚本写好再自己编译
![](https://img.haomeiwen.com/i10074549/8135e806aab8f5a9.png)
把本地jre写进脚本
![](https://img.haomeiwen.com/i10074549/29d486a47b2b5743.png)
![](https://img.haomeiwen.com/i10074549/f6bffd7e8976460a.png)
Source: "自己本地JRE路径*"; DestDir: "{app}{#MyJreName}"; Flags: ignoreversion recursesubdirs createallsubdirs
![](https://img.haomeiwen.com/i10074549/a110c15d3502d7f0.png)
![](https://img.haomeiwen.com/i10074549/380040da98848e09.png)
然后直接编译,会提示保存当前脚本,随便起个名字,下个还可以继续用
![](https://img.haomeiwen.com/i10074549/050282bf6c4a35a6.png)
![](https://img.haomeiwen.com/i10074549/99276190b31180f6.png)
![](https://img.haomeiwen.com/i10074549/1ecf0dc56e437655.png)
网友评论