简体   繁体   English

在Ubuntu中设置Java变量

[英]Setting up the Java variables in Ubuntu

I am trying to install Amazon Mturk command line tool on Ubuntu 13.10 ( 32-bit) system. 我正在尝试在Ubuntu 13.10(32位)系统上安装Amazon Mturk命令行工具。

After setting the access secrete and access identifier in mturk.properties file, I ran the getBalance.sh file and below is the output. 在mturk.properties文件中设置访问权限和访问标识符后,我运行了getBalance.sh文件,下面是输出。

./getBalance.sh
You must set JAVA_HOME (i.e. export JAVA_HOME=/usr)
If you do not have JAVA on your machine, you can download it from http://java.sun.com/
./../bin/invoke.sh: 41: exit: Illegal number: -1

The following is the java information on my system 以下是我系统上的Java信息

$ file `which java javac`
/usr/bin/java:  symbolic link to `/etc/alternatives/java'
/usr/bin/javac: symbolic link to `/etc/alternatives/javac'

My shell information is : 我的外壳信息是:

$ echo $SHELL
/bin/bash

But, $JAVA_HOME command gave me a blank line as result. 但是,$ JAVA_HOME命令给了我一个空白行。

I can see the java installed on my machine : 我可以看到我的机器上安装了java:

$ which java
/usr/bin/java

$ java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1~0.13.10.1)
OpenJDK Server VM (build 24.51-b03, mixed mode)

Then I ran the following commands: 然后我运行以下命令:

$ export JAVA_HOME=/usr/bin/java
$ echo $JAVA_HOME
/usr/bin/java

I thought everything is correct now, but here is what I get if I run the getBalnace.sh 我以为现在一切都正确了,但是如果运行getBalnace.sh,这就是我所得到的

$ ./getBalance.sh 
./../bin/invoke.sh: 79: exec: /usr/bin/java/bin/java: not found

I checked my environment variables, below is the result 我检查了环境变量,结果如下

$ env | grep java
JAVA_HOME=/usr/bin/java
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript

And the path is: 路径是:

$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sid/.rvm/bin

I still could not figure out where am I doing wrong. 我仍然不知道我在哪里做错了。 The sentences below are quite confusing and no much information is available. 下面的句子很混乱,没有太多可用信息。

  • If you downloaded the Unix distribution, you must set the MTURK_CMD_HOME environment variable to point to your Command Line Tools installation location. 如果下载了Unix发行版,则必须将MTURK_CMD_HOME环境变量设置为指向命令行工具的安装位置。
  • If you downloaded the Unix distribution, you must set the JAVA_HOME environment variable to point to your Java Standard Edition Runtime Environment (JRE) installation location. 如果下载了Unix发行版,则必须将JAVA_HOME环境变量设置为指向Java Standard Edition Runtime Environment(JRE)安装位置。

Any help would be much appreciated. 任何帮助将非常感激。

In the Java world, JAVA_HOME refers to the directory where the JDK or JRE was installed. 在Java世界中,JAVA_HOME是指JDK或JRE的安装目录。 So you should be able to find the java executable at 因此,您应该能够在以下位置找到java可执行文件

$JAVA_HOME/bin/java

In your case, find the physical location where java is installed. 根据您的情况,找到安装Java的物理位置。 Something like this should work: 这样的事情应该起作用:

readlink -f /usr/bin/javac

A typical response would be 一个典型的响应是

/usr/lib/jvm/java-7-openjdk-amd64/bin/javac

For this response, you should set JAVA_HOME to 对于此响应,应将JAVA_HOME设置为

/usr/lib/jvm/java-7-openjdk-amd64

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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