java 从命令提示符运行可执行 jar 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15246711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 18:58:22  来源:igfitidea点击:

Running executable jar file from command prompt

java

提问by lspriya87

How to run a jar file which holds a java program from command prompt?

如何从命令提示符运行包含 Java 程序的 jar 文件?

Getting following exception while trying to run

尝试运行时出现以下异常



Exception in thread "main" java.lang.NullPointerException at sun.launcher.LauncherHelper.getMainClassFromJar(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

线程“main”中的异常 java.lang.NullPointerException at sun.launcher.LauncherHelper.getMainClassFromJar(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)



回答by j0chn

Just go to the directory with "cd path to jar file".
And there you enter "filename.jar" and hit enter.
For me this works fine.

Edit: I put the "filename.jar" into brackets and the compiler did not show the filename.

只需转到带有“cd jar 文件路径”的目录即可。
在那里你输入“filename.jar”并按回车键。
对我来说这很好用。

编辑:我把“filename.jar”放在括号里,编译器没有显示文件名。