简体   繁体   English

运行已构建的jar时发生ClassNotFoundException

[英]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.

相关问题 运行jar时发生ClassNotFoundException - ClassNotFoundException while running jar 运行可执行jar时出现问题:ClassNotFoundException即将到来 - Issue while running executable jar : ClassNotFoundException coming 运行 JAR 时出现 ClassNotFoundException,在 IntelliJ IDEA 中运行时没有错误 - ClassNotFoundException upon running JAR, no errors while running in IntelliJ IDEA 运行jar时发生ClassNotFoundException,尽管它包含所有tha类 - ClassNotFoundException while running a jar though it contails all tha classes 在 Amazon Kinesis Streaming Analytics 应用程序上运行 jar 时出现 ClassNotFoundException - ClassNotFoundException while running jar on Amazon Kinesis Streaming Analytics app 运行使用Gradle构建的JAR文件时,“没有主清单属性” - 'No main manifest attribute' while running JAR file built with Gradle 运行hadoop jar时发生ClassNotFoundException - ClassNotFoundException when running hadoop jar 运行程序时发生ClassNotFoundException - ClassNotFoundException while running program 运行可执行jar时ClassNotFoundException - ClassNotFoundException when running executable jar 通过命令行运行JAR时发生错误java.lang.ClassNotFoundException:com.mysql.jdbc.Driver - Error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver while running JAR through Command line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM