Cannot find class even when jar file is in working directory

為{幸葍}努か 提交于 2019-12-03 16:53:05

When using the -jar option, you need to specify which jar-files should be on your class path in the manifest file. Just having the required jar files in the same directory won't do it.

Add a line in your manifest that says:

Class-Path: JAXB2_20081030.jar:JAXB2_20110601.jar:....:netty-3.2.4.Final.jar

or skip the -jar option and launch using

java -cp JAXB2_20081030.jar:....:netty-3.2.4.Final.jar:jRams.jar pkg.JRamsMain

and it should work fine.

(Note that on *nix systems, as opposed to Windows machines, the jar files in the class paths should be separated using : instead of ;.)

Further reading:

You need to add all those JARs to the runtime CLASSPATH by adding the -classpath parameter. AIX requires you to separate the JARs using :

You will have to specify the full path(if libraries not in the same directory as jRams) or just the names of the jar file in a manifest file (If all dependency jars are in the same folder). Alternative specify the path to all the dependent jars using -cp argument.

Example (This assume every dependency is in the same directory you are executing java command from):

java -cp commons-collections-3.2.1.jar; jaxb-impl.jar; etc.. ;jRams.jar package_to_class.MyMainClass.java

Where package_to_class is example: com.myproj.example.

EDITED.

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