[英]ClassNotFoundException while running already-built jar
I added the jar for com.drew.* which is :- 我为com.drew。*添加了jar,它是:-
metadata-extractor-2.4.0-beta-1.jar
I am also able to build my application in Eclipse without any error. 我还可以在Eclipse中构建应用程序而不会出现任何错误。 But when I run my application's jar (that includes all the required jars including the above one), I get the following error:
但是,当我运行应用程序的jar(包括上述所有必需的jar)时,出现以下错误:
Error: java.lang.ClassNotFoundException: com.drew.imaging.jpeg.JpegMetadataReader
Any suggestions? 有什么建议么?
Thanks in advance.. 提前致谢..
Open executable jar (using 7z
/ WinRAR
, etc.) and look if there is your metadata-extractor
jar included - also open your Manifest and see if this jar is in the classpath. 打开可执行jar(使用
7z
/ WinRAR
等),查看是否包含您的metadata-extractor
jar-也打开清单,查看此jar是否在类路径中。
In case everything above is fine I think there is probably jar dependency version mismatch. 如果以上一切都很好,我想可能是jar依赖版本不匹配。
Do you exporting your executable jar using Eclipse File->Export->Runnable JAR file? 您是否使用Eclipse File-> Export-> Runnable JAR文件导出可执行jar? It should work just as in the Eclipse
它应该像在Eclipse中一样工作
You need to provide the classpath in MANIFEST.MF file. 您需要在MANIFEST.MF文件中提供类路径。 You can view this file using any extractor tool.
您可以使用任何提取器工具查看此文件。 If dependent jar is in folder than provide the folder name in classpath Entry should look like
如果从属jar在文件夹中,则在类路径中提供文件夹名称。
Class-Path: folder/jarfilename
This will help you further http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html 这将帮助您进一步http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html
It looks like with eclipse when building a jar you have to choose which resources you would like to be included . 在构建一个jar时,看起来就像带有eclipse一样,您必须选择要包含的资源 。 Maybe you did not select that jar?
也许您没有选择那个罐子?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.