在 Linux 上安装 Java EE SDK 的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2224321/
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
Problems installing Java EE SDK on Linux
提问by David Titarenco
I installed the Java 6 JRE on my VPS just fine, but I can't get the EE SDK installation to even run.
我在 VPS 上安装了 Java 6 JRE 就好了,但我什至无法运行 EE SDK 安装。
root@vps [/usr/java]# java -version
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode)
However, when I try to run java_ee_sdk-6-unix.sh
:
但是,当我尝试运行时java_ee_sdk-6-unix.sh
:
./ ../ java_ee_sdk-6-unix.sh* jre1.6.0_18/ jre.bin*
root@vps [/usr/java]# ./java_ee_sdk-6-unix.sh
Could not locate a suitable jar utility.
Please ensure that you have Java 6 or newer installed on your system
and accessible in your PATH or by setting JAVA_HOME
But the catch is that I set my environment variables correctly:
但问题是我正确设置了环境变量:
root@vps [/usr/java]# echo $PATH
/usr/java/jre1.6.0_18:/usr/java/jre1.6.0_18/bin:/usr/java/jre1.6.0_18/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
root@vps [/usr/java]# export -p | grep JAVA_HOME
declare -x JAVA_HOME="/usr/java/jre1.6.0_18"
I'm pulling my hair out here, any ideas?
我在这里拉我的头发,有什么想法吗?
采纳答案by matt b
Do you have a JDK installed? You likely want to put $JDK_HOME/bin
on your PATH, not the /bin
of a JRE, as jar
comes with JDK, not JRE.
你安装了JDK吗?您可能希望使用$JDK_HOME/bin
PATH,而不是/bin
JRE 的PATH,这是jar
JDK 附带的,而不是 JRE。
回答by Dave Jarvis
Do this:
做这个:
- Delete all installations of Java.
- Install the Java SDK(self-extracting) into /opt/jdk1.6.0_16(for example)
- Create a symbolic link:
ln -s /opt/jdk1.6.0_16 /opt/jdk
Edit
$HOME/.bashrc
:JAVA_HOME=/opt/jdk
PATH=$PATH:$HOME/bin:$JAVA_HOME/binLogout and log back in.
- 删除所有 Java 安装。
- 将Java SDK(自解压)安装到/opt/jdk1.6.0_16(例如)
- 创建符号链接:
ln -s /opt/jdk1.6.0_16 /opt/jdk
编辑
$HOME/.bashrc
:JAVA_HOME=/opt/jdk
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin注销并重新登录。
This offers many advantages:
这提供了许多优点:
- You can install multiple versions of the SDK and need only switch a symbolic link.
- You know where all the files are located.
- You know exactly which version of Java is being used.
- No other versions are installed, so there cannot be any conflicts.
- 您可以安装多个版本的SDK,只需要切换一个符号链接。
- 您知道所有文件的位置。
- 您确切地知道正在使用哪个版本的 Java。
- 没有安装其他版本,所以不会有任何冲突。
I have done this for years and have never had any problems with Java on Linux, except for packages that do not detect that Java is installed and attempt to install the OpenJDK.
我已经这样做了多年,在 Linux 上使用 Java 从来没有遇到过任何问题,除了没有检测到 Java 已安装并尝试安装 OpenJDK 的软件包。
Also, stay away from the OpenJDK as its fonts are terrible to behold.
另外,远离 OpenJDK,因为它的字体很难看。
回答by Ramu Nachiappan
In my case, I had jdk1.6.0_16 extracted in my home directory and had a symbolic links to java
and /javac
in /bin
. Then I encountered the error described above in the question.
就我而言,我在我的主目录中提取jdk1.6.0_16,有一个符号链接java
,并/javac
在/bin
。然后我遇到了问题中上面描述的错误。
However once I included a symbolic link to jar
in /bin
, the shell script to install Java EE ran as expected.
但是,一旦我包含了指向jar
in的符号链接/bin
,安装 Java EE 的 shell 脚本就会按预期运行。
回答by Javier Garay
This info works for me... The first method was enought.
这个信息对我有用......第一种方法已经足够了。
Regards.
问候。
http://ubuntuforums.org/showthread.php?p=11485538#post11485538
http://ubuntuforums.org/showthread.php?p=11485538#post11485538
回答by Lorenzo Solano
My 2 cents...
我的 2 美分...
I have the same problem and solve it by installing a jar utility.
我有同样的问题并通过安装 jar 实用程序来解决它。
As "matt b"said the problem was (well my problem), that the installer was not finding a jar utility (jar program), needed to run the installation files.
正如“matt b”所说,问题是(我的问题),安装程序没有找到运行安装文件所需的 jar 实用程序(jar 程序)。
Do you have a JDK installed? You likely want to put $JDK_HOME/bin on your PATH, not the /bin of a JRE, as jar comes with JDK, not JRE.
你安装了JDK吗?您可能希望将 $JDK_HOME/bin 放在 PATH 中,而不是 JRE 的 /bin 中,因为 jar 是 JDK 附带的,而不是 JRE。
But in my case (having Ubuntu 11.10 x64 and JAVA_HOME --> /usr/lib/jvm/java-6-openjdk) the problem was not fixed by setting the JDK/bin dir on the PATH. Instead I had to install a jar utility package (using Synaptic) called Jarwrapper version 0.37ubuntu1.
但在我的情况下(有 Ubuntu 11.10 x64 和 JAVA_HOME --> /usr/lib/jvm/java-6-openjdk)问题并没有通过在 PATH 上设置 JDK/bin 目录来解决。相反,我必须安装一个名为 Jarwrapper 版本 0.37ubuntu1 的 jar 实用程序包(使用 Synaptic)。
After installing it, the installation script of Oracle's JDK (java_ee_sdk-6u3-jdk7-linux-x64-ml.sh) ran just fine.
安装后,Oracle的JDK安装脚本(java_ee_sdk-6u3-jdk7-linux-x64-ml.sh)运行正常。
Regards,
问候,
回答by biera
I got the same error. I removed OpenJDK using apt-get (I'm running Ubuntu 11.10) then downloaded Java JDK 1.7 (which comes of course with JRE) and unpacked this under /usr/local/java - this gave me new directory:
我得到了同样的错误。我使用 apt-get(我正在运行 Ubuntu 11.10)删除了 OpenJDK,然后下载了 Java JDK 1.7(它当然与 JRE 一起提供)并在 /usr/local/java 下解压 - 这给了我新目录:
/usr/local/java/jdk1.7.0_04
Next I added:
接下来我补充说:
/usr/local/java/jdk1.7.0_04
to $PATH, set $JAVA_HOME and $JRE_HOME as
到 $PATH,将 $JAVA_HOME 和 $JRE_HOME 设置为
/usr/local/java/jdk1.7.0_04
/usr/local/java/jdk1.7.0_04/jre
respectively.
分别。
Everything works nice. I can compile java progams using javacand run them using java. Jarprogram runs fine as well. So why does java ee installer complain about that? Any clues as how to fix that?
一切正常。我可以使用javac编译 java 程序并使用java运行它们。Jar程序也运行良好。那么为什么 java ee 安装程序会抱怨呢?关于如何解决这个问题的任何线索?
回答by janex
Quick and dirty solution for me:
对我来说快速而肮脏的解决方案:
sudo apt-get install jarwrapper fastjar
Then just run your .sh script and voila!
然后运行你的 .sh 脚本,瞧!
回答by Roy
I had the problem, however it was related to the sudo user account when executing the .sh file. I was installing Glassfish v3 on a new VPS hosted server with Ubuntu 10.4 64Bit OS.
我遇到了问题,但是它与执行 .sh 文件时的 sudo 用户帐户有关。我正在使用 Ubuntu 10.4 64Bit OS 的新 VPS 托管服务器上安装 Glassfish v3。
sudo chmod +x java_ee_sdk-6u2-jdk-linux-x64.sh
sudo ./java_ee_sdk-6u2-jdk-linux-x64.sh -s -a java_ee_sdk-6u2-jdk-linux-x64-install-answers.txt
Only to get the exact same error you were first experiencing:
只是为了得到您第一次遇到的完全相同的错误:
Could not locate a suitable jar utility.
Please ensure that you have Java 6 or newer installed on your system
and accessible in your PATH or by setting JAVA_HOME
Silly really, when I ran the command like this:
真的很傻,当我像这样运行命令时:
./java_ee_sdk-6u2-jdk-linux-x64.sh -s -a java_ee_sdk-6u2-jdk-linux-x64-install-answers.txt
To my suprise it responded with:
令我惊讶的是,它的回应是:
Welcome to GlassFish V3 installer
Using the user defined JAVA_HOME : /opt/jdk
Entering setup...
This was after I had setup my JAVA_HOME in file: /etc/bash.bashrc
这是在我在文件中设置我的 JAVA_HOME 之后: /etc/bash.bashrc
JAVA_HOME=/opt/jdk
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH