java jar:在 Bash 中找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4689817/
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
jar: command not found in Bash
提问by dhananjay
I created one jar file in following location: '/usr/local/bin/niidle.jar'
我在以下位置创建了一个 jar 文件:'/usr/local/bin/niidle.jar'
But when I type command as follows:
但是当我按如下方式输入命令时:
jar tf /usr/local/bin/niidle.jar
then it shows the following error:
然后它显示以下错误:
--The program 'jar' can be found in the following packages:
* java-gcj-compat-headless
* gcj-4.2
* sun-java5-jdk
* kaffe
* gcj-4.3
* cacao-oj6-jdk
* openjdk-6-jdk
* fastjar
* sun-java6-jdk
Try: apt-get install <selected package>
bash: jar: command not found
Do you have a solution for this?
你有解决办法吗?
回答by Péter T?r?k
Apparently the jar
program is not found by the operating system. Have you installed any of the packages containing it, and set up your path correctly?
显然,jar
操作系统找不到该程序。您是否安装了任何包含它的软件包,并正确设置了您的路径?
In order for the OS to find an executable, the path
environment variable must include the directory where that program is located. Otherwise you need to specify its full path to access it.
为了让操作系统找到可执行文件,path
环境变量必须包含该程序所在的目录。否则,您需要指定其完整路径才能访问它。
回答by Jon Skeet
Well, it can't find the jar
program. Perhaps your JDK isn't on the path, or you haven't installed one? If you haveinstalled one, try to find where it is, and look in there for the jar
program.
嗯,它找不到jar
程序。也许您的 JDK 不在路径上,或者您还没有安装?如果您已经安装了一个,请尝试找到它的位置,然后在那里查找该jar
程序。
回答by ChadNC
Try runnning "java -jar /usr/local/bin/niidle.jar"
尝试运行“java -jar /usr/local/bin/niidle.jar”
回答by Juan Rojas
On Ubuntu 12.10 The program jar is in /usr/lib/jvm/jdk-[version]/bin edit the file /etc/environment for add to the path. Close the session and open a new session.
在 Ubuntu 12.10 上,程序 jar 在 /usr/lib/jvm/jdk-[version]/bin 编辑文件 /etc/environment 以添加到路径。关闭会话并打开一个新会话。
回答by Innokenty
If you are like me and you already have everything installed, but you just get the same error when trying to type jar
: it should be listed in your PATH
.
如果您像我一样并且已经安装了所有东西,但是在尝试键入时会遇到相同的错误jar
:它应该列在您的PATH
.
- Run
echo $PATH
. - If you're like me, it does not contain the entry like this
/usr/lib/jvm/jdk1.8.0_66/bin
. - Make sure it's not
$JAVA_HOME/bin
, all variables should be expanded! - If you don't have the entry, but have
JAVA_HOME
set, runexport PATH=$PATH:$JAVA_HOME/bin
- See if you got the
jar
command. - If it does, google about environment variables to set that effect forever.
- Have a nice day.
- 运行
echo $PATH
。 - 如果你像我一样,它不包含这样的条目
/usr/lib/jvm/jdk1.8.0_66/bin
。 - 确保它不是
$JAVA_HOME/bin
,所有变量都应该被扩展! - 如果您没有条目,但已
JAVA_HOME
设置,请运行export PATH=$PATH:$JAVA_HOME/bin
- 看看你有没有收到
jar
命令。 - 如果是这样,请搜索有关环境变量的 google 以永久设置该效果。
- 祝你今天过得愉快。
回答by Twister
You seems to be using either Debian or Ubuntu. And it is telling you that you did not install one of the packages containing the 'jar' executable. You will have to install one corresponding to the java package you use on your system. In order to know which java package you already have type this : dpkg -l | grep java
您似乎在使用 Debian 或 Ubuntu。它告诉您您没有安装包含“jar”可执行文件的软件包之一。您必须安装一个与您在系统上使用的 java 包相对应的包。为了知道您已经拥有哪个 java 包,请输入: dpkg -l | 爪哇