为应用程序创建 jar 文件,该文件又包含外部 jar 文件
大家好,
我想为 java 应用程序创建一个 jar 文件,并且我能够正确地为其创建 jar 文件。我按照以下链接创建了 jar 文件。在此处输入链接描述
但我面临的问题是,在我的应用程序中,我添加了外部 jar,例如 jna.jar 、 platform.jar 和vlcj-1.2.0-javadoc.jar 文件成功运行我的应用程序。当我在 eclipse 中运行时,该应用程序将运行良好,但是当我为同一应用程序创建远文件时,我收到如下错误 未发现类定义错误。 jna 本机库丢失。
所以请您告诉我实际问题是什么以及如何解决它。在创建 jar 文件时,我还启用了“导出 java 源文件和资源”选项。
提前致谢 达塔
Hie all ,
I want to create an jar file for a java application, and i am able create the jar file for it properly.i followed the below link to create the jar file .enter link description here
But the problem what i am facing is that in my application i added the external jar's like jna.jar , platform.jar and vlcj-1.2.0-javadoc.jar files to run my application successful. This application will run fine when i run in eclipse , but when i create the far file for the same application I'm getting the error like
No class defination found error.
jna native library missing.
so please will you tell me what is the actual problem and how do I solve it . and one more thing while creating the jar file I enabled the option "Export java source files and resources".
thanks in advance
Datta
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运行应用程序时,您必须提供完整的类路径,即:
java -cp myapp.jar;jna.jar;platform.jar com.mycompany.MyMain
如果您使用 -jar选择您应该将所有第三方库打包到 META-INF 下的 jar 中的 manifest.mf 中,即添加如下行:
Class-Path: jna.jar platform.jar
到您的清单中。
使用时要注意;对于 Windows 命令行, : 对于 unix 命令行,在清单中写入类路径时需要空格。
You have to supply full class path when you are running your application, i.e. something like:
java -cp myapp.jar;jna.jar;platform.jar com.mycompany.MyMain
If you are using -jar option you should put all third party libraries to manifest.mf packaged into your jar under META-INF, i.e. add line like:
Class-Path: jna.jar platform.jar
to you manifest.
Pay attenition that you should use ; for windows command line, : for unix command line and space when writing class path in manifest.