简体   繁体   English

如何使用外部库运行Jar文件?

[英]How to run a Jar-file with external libraries?

When I run the Jar-file inside netbeans it works. 当我在netbeans中运行Jar文件时,它可以工作。 But after I clean and build it, it won't run. 但是,在我清理并构建它之后,它将无法运行。 It gives me an error, that the Mainclass couldn't be found. 这给我一个错误,找不到主类。

I tried already something like: 我已经尝试过类似的东西:

java -cp C:\javaProjectsTests\J.jar;C:\javaProjectsTests\lib\*;. j.J

java -Djava.library.path=C:\javaProjectsTests\lib\* -jar C:\javaProjectsTests\J.jar

Maybe someone could help? 也许有人可以帮忙?

Please refer below link Execute jar file with multiple classpath libraries from command prompt 请参考以下链接,从命令提示符处执行带有多个类路径库的jar文件

Lod your jars to classpath and execute your class (with main method) 将jars放置到classpath并执行您的类(使用main方法)

Thanks, 谢谢,

It was a syntaxerror in the path-string. 这是路径字符串中的语法错误。

It works now, but only if the lib-folder(other jar-files) is in the same directory as the executing jar-file. 现在可以使用,但前提是lib-folder(其他jar文件)与正在执行的jar文件位于同一目录中。 Should not a problem for comandline programs, as it's possible to use a batch-file to execute from somewhere else. comandline程序应该没有问题,因为可以使用批处理文件从其他地方执行。

However I asked me if it's possible to merge archives, as I could read on a website here ? 但是我问我是否可以合并档案,因为我可以在这里的网站上阅读?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM