Adding jar to classpath when running from command line

我们两清 提交于 2019-11-30 12:12:27

Your problem is min separator you are using. Separator ; is for windows. On Unix systems you should use : instead:

java -classpath "bin:mysql-connector-java-5.1.19-bin.jar" MyProgram

Use a ':' to separate your entries on Unix systems:

java -classpath "bin:mysql-connector-java-5.1.19-bin.jar" MyProgram
java -cp bin:mysql-connector-java-5.1.19-bin.jar MyProgram

Eclipse converts it automatically.

See:

String pathSeparator = System.getProperty("path.separator");

you did not set your main class in classpaht, try add ./ in -cp

I would highly suggest you try --jar or -jar. I can't remember which it is, but those should settle you. Also, if you have the dev tools from apple, they have a jar packager.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!