简体   繁体   中英

Calling and opening jar file from command line OS X

I have an issue, which relates to starting a jar file.

I have my code in java, and i have to export it to get a jar file. I do that, and i get a jar file, however, now i want to call my jar file from the command line. I set my main class in my jar file, so that i have an entry point. My java code depends on another jar file, and i am not sure, if it has anything to do with my problem.

Then i call the file from command line, after i have positioned myself in the right folder. I use the command : java -jar Likvidator2.jar

And what i get is this :

错误信息

I have tried checking my java version, and updating it, but at this point i really am not sure what to do and where to go anymore. Is it possible that i am building my project wrong, or something ?

您需要将类路径添加到命令中。

java -classpath <pathtodependency.jar;pathtootherdep.jar> your.MainClass

@Jan Doerrenhaus所述,您应该使用Maven Shade插件来创建可执行的JAR。

[SOLVED]

I just had to build the jar file as runnable jar file, and everything worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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