java 如何解决错误:“jar”不是内部或外部命令、可运行的程序或批处理文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43514577/
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-11-03 07:29:54  来源:igfitidea点击:

How can I solve the error : 'jar' is not recognized as an internal or external command, operable program or batch file?

javajar

提问by Code_Ninja

I'm getting the following error when I try to run the 'jar' command in the command line on windows : 'jar' is not recognized as an internal or external command.

我收到以下错误,当我尝试运行“jar在Windows命令行”命令:'jar' is not recognized as an internal or external command

There is a general guess that seems to be right that is I might have the PATHenvironment variable incorrectly. But I have already done this, I added the following value to PATHvariable : 'C:\Program Files(x86)\Java\jdk1.8.0_25\bin'.

有一个普遍的猜测似乎是正确的,即我可能PATH错误地设置了环境变量。但是我已经这样做了,我在PATH变量中添加了以下值:' C:\Program Files(x86)\Java\jdk1.8.0_25\bin'。

I am running a 64 bit windows 8 system. I have also referenced this question from the following link: java 'jar' is not recognized as an internal or external command

我正在运行 64 位 Windows 8 系统。我还从以下链接中引用了这个问题: java 'jar' is notknowledge as an internal or external command

I have also tried some of the solutions suggested in the above link, I couldnt add a comment there since my reputation is not much.

我也尝试了上面链接中建议的一些解决方案,我无法在那里添加评论,因为我的声誉并不高。

Suggestions that I have tried from the above link:

我从上面的链接中尝试过的建议:

[1]https://stackoverflow.com/a/29180681/7639034

[1] https://stackoverflow.com/a/29180681/7639034

(From the above link, java -version and java -jar are also working. What is wrong with the jar file then?)

(从上面的链接,java -version 和 java -jar 也可以工作。那么 jar 文件有什么问题?)

[2]https://stackoverflow.com/a/42492380/7639034

[2] https://stackoverflow.com/a/42492380/7639034

回答by Pradeep Simha

Path variable should be pointing to binfolder, that's where executable are stored. Currently you are having path only upto C:\Program Files(x86)\Java\jdk1.8.0_25so you are getting error.

路径变量应该指向bin文件夹,这是存储可执行文件的地方。目前您只有 upto 路径,C:\Program Files(x86)\Java\jdk1.8.0_25因此您会收到错误消息。

Create JAVA_HOMEenvironment variable which points to above location, and add %JAVA_HOME%\binto PATHvariable. It will work.

创建JAVA_HOME指向上述位置的环境变量,并添加%JAVA_HOME%\binPATH变量中。它会起作用。

回答by Nadav Tasher

try

尝试

java -jar [YOURJAR]

this should work to execute jars

这应该可以执行 jars