1:首先一个编写一个java文件,简单的一个main方法入口
public class HelloWorld{
public static void main(String[] args){
System.out.println("HelloWorld");
System.out.println("HelloWorld");
System.out.println("HelloWorld");
}
}
2:使用javac 编译成HelloWorld.class文件
3:准备一个MANIFEST.MF文件,Main-Class填写自己要转为exe的文件
Manifest-Version: 1.0
Main-Class: HelloWorld
4:执行命令行,jar cvfm anyName.jar MANIFEST.MF HelloWorld.class 生成 anyName.jar 文件,执行java -jar anyName.jar 可以正常运行,即打包正常
5: 去下载exe4j 版本: https://www.ej-technologies.com/download/exe4j/files ,选择release版本,64bit的 ZIP
6:下载exe4j成功,打开界面如下,点击下一步
7:选择JAR IN EXE mode选项,点击下一步
8:给自己的exe命名并选择自己本地放置路径,点击下一步
9:其中1位置处,选择console application 适用项目后台输出;2,3位置处选择对应的JVM环境,点击下一步
10: 选择自己刚刚打好的jar包,并选择Main class
11: 填写JRE version,后面就直接点击下一步,不需修改
12:点击到这个页面,helloWorld.exe也正常生成,可以点击Click here to Start the Application,也可找到对应路径下的exe文件直接执行
13:执行效果如图,步骤完成