linux 下java jar包的方法

 

test.java 和 example.jar 在同一目录;并且test.java引用了example.jar

首先编译test.java:

javac -cp example.jar test.java

然后执行 test.class

java -cp example.jar test

然后出错 “错误: 找不到或无法加载主类 test"

原来引用文件后面要加上冒号":"  (windows可能要加上";")

java -cp example.jar: test

OK

原文地址:https://www.cnblogs.com/shaohz2014/p/3685737.html