1. linux必须已安装java环境,测试
#javac -versionjavac 1.8.0_20
说明java环境已安装好了
2. 建立目录helloworld,在目录下建立helloworld.java文件
#cd ~~# mkdir helloworld~# cd helloworld~/helloworld# vi helloworld.java
helloworld.java内容如下
public class helloworld { public static void main(String[] args) { System.out.println("Hello World!!"); }}
把helloworld.java 打包成可执行的jar
~/helloworld# javac helloworld.java~/helloworld# ls~/helloworld# echo Main-class: helloworld > manifest.txt~/helloworld# ls~/helloworld# cat manifest.txt~/helloworld# jar cvfm hello.jar manifest.txt helloworld.class
屏幕显示如下打包信息:
运行hello.jar文件
~/helloworld# ls~/helloworld# java -jar hello.jarhello world!!