java 'jar' 不被识别为内部或外部命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29180639/
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
java 'jar' is not recognized as an internal or external command
提问by Coder Lam
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
当我尝试在 Windows 的命令行中运行“jar”命令时出现以下错误:“jar”未被识别为内部或外部命令
The general solution seems to be that I need to add the jdk bin folder to the PATH in environment variables. I have already done this, I added the following to the path variable : ...; C:\Program Files\Java\jdk1.8.0_40\bin\;
一般的解决方案似乎是我需要将jdk bin文件夹添加到环境变量中的PATH中。我已经这样做了,我在路径变量中添加了以下内容:...; C:\Program Files\Java\jdk1.8.0_40\bin\;
Though I'm not sure if having the jdk reside in 'program files' instead of 'program files x86' affects this. I'm on 64 bit windows with 64 bit java. Thanks
虽然我不确定将 jdk 驻留在“程序文件”而不是“程序文件 x86”中是否会影响这一点。我在带有 64 位 java 的 64 位 Windows 上。谢谢
采纳答案by Joseph Mekwan
The path should only contain directories where the OS will look for executables. Strip the trailing "\jar.exe" to set your path as:
该路径应仅包含操作系统将在其中查找可执行文件的目录。去除尾随的“\jar.exe”以将您的路径设置为:
(old path variables here);C:\Program Files (x86)\Java\jdk1.7\bin
(旧路径变量在这里);C:\Program Files (x86)\Java\jdk1.7\bin
Thanks To : @stevevls
感谢:@stevevls
回答by Aleksandr ?mailov
Try using this command:
尝试使用此命令:
java -version
If it doesn't work that means you failed to properly add path to jdk. If it does work, try using:
如果它不起作用,则意味着您未能正确添加 jdk 路径。如果确实有效,请尝试使用:
java -jar
回答by Przemek Nowak
The jarcommand in command line is used in order to create a JAR file. For example:
命令行中的jar命令用于创建 JAR 文件。例如:
jar cf jar-file input-file(s)
See more at: Oracle docs
查看更多信息:Oracle 文档
If you want to run the existed JAR file you should use the java -jarcommand mentioned by @Aleksandr.
如果你想运行现有的 JAR 文件,你应该使用@Aleksandr 提到的java -jar命令。
But in your case it looks like you don't have an access to the added directory in your path with JKD binaries so at the beginning try to execute mentioned java --versionto check whether you have java in you classpath at all.
但是在您的情况下,您似乎无法使用 JKD 二进制文件访问路径中添加的目录,因此在开始时尝试执行提到的java --version以检查您的类路径中是否有 java。
Please remember that on Windows you have to restart the console when you change the windows default path. You do not see the changes on the current console.
请记住,在 Windows 上,更改 Windows 默认路径时必须重新启动控制台。您看不到当前控制台上的更改。
The x64 version of Java is installed on Program Files. The x86 version is installed on Program Files x86by default.
x64 版本的 Java 安装在Program Files 上。x86 版本默认安装在Program Files x86 上。
回答by Manukundloo
Five steps to solve this problem:
解决这个问题的五个步骤:
- check whether in your
bin
folder jar.exe is availbale or not - check for your environmental setting
- download jar file from here http://originaldll.com/file/jar.exe/29248.htmland keep in
bin
folder - now check for jar it will 100% work
- keep any jar in your desktop and go to desktop path on cmd prompt and run the command
jar xf filename.jar
- 检查您的
bin
文件夹中的 jar.exe 是否可用 - 检查您的环境设置
- 从这里下载 jar 文件http://originaldll.com/file/jar.exe/29248.html并保存在
bin
文件夹中 - 现在检查 jar 它将 100% 工作
- 在桌面上保留任何 jar 并在 cmd 提示符下转到桌面路径并运行命令
jar xf filename.jar
Now see if it is working
现在看看它是否工作