在 Ubuntu 10.04 上安装 Java JDK

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

Installing Java JDK on Ubuntu 10.04

ubuntujava

提问by NullUserException

Ever since I upgraded my Ubuntu from 9.10 to 10.04 I can't start Netbeans any more, because apparently they are dropping support for Java's JDK in favor of OpenJDK. Well, problem is, my IDEs won't work with OpenJDK.

自从我将 Ubuntu 从 9.10 升级到 10.04 后,我再也无法启动 Netbeans,因为显然他们正在放弃对 Java JDK 的支持,转而支持 OpenJDK。好吧,问题是,我的 IDE 不能与 OpenJDK 一起使用。

apt-get install sun-java6-jdkis not working. I downloaded the Linux installation file from Sun (jdk-6u21-linux-i586.bin) and installed it, but I can't call java or javac from the terminal.

apt-get install sun-java6-jdk不管用。我从Sun下载了Linux安装文件(jdk-6u21-linux-i586.bin)并安装了,但是在终端无法调用java或javac。

Can anyone help me here?

有人能帮我一下吗?

回答by Pablo Santa Cruz

Hereis how you would install it.

是您安装它的方法。

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6

Good luck.

祝你好运。

回答by zengr

How to install Java6 JDK on Ubuntu 10.04

如何在 Ubuntu 10.04 上安装 Java6 JDK

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

sudo apt-get update
sudo apt-get install sun-java6-jdk

回答by Devon_C_Miller

The NetBeans installation has a reference to the JDK that is created at install time. After the upgrade to 10.04, that reference is no longer valid.

NetBeans 安装引用了在安装时创建的 JDK。升级到 10.04 后,该引用不再有效。

Go to the directory where you installed NetBeans. By default it is "/usr/local/netbeans-version" if you installed as root or "$HOME/netbeans-version" if you installed as a regular user. There will be a subdirectory named "etc". In that directory, edit the "netbeans.conf" file. Look for the netbeans_jdk_homeand change it to /usr/lib/jvm/java-6-openjdk.

转到安装 NetBeans 的目录。默认情况下,如果您以 root 身份安装,则为“/usr/local/netbeans- version”;如果您以普通用户身份安装,则默认为“$HOME/netbeans- version”。将有一个名为“etc”的子目录。在该目录中,编辑“netbeans.conf”文件。查找netbeans_jdk_home并将其更改为/usr/lib/jvm/java-6-openjdk

回答by Jesper

I downloaded the Linux installation file from Sun (jdk-6u21-linux-i586.bin) and installed it, but I can't call java or javac from the terminal.

我从Sun下载了Linux安装文件(jdk-6u21-linux-i586.bin)并安装了,但是在终端无法调用java或javac。

You missed the final step: after installing the JDK manually (instead of from the package system), you need to add the bindirectory of your JDK to the PATH. The best way to do that in Ubuntu 10.04 is to edit the file /etc/environment: sudo nano /etc/environment. Log out and back in and you should be able to run Java.

您错过了最后一步:手动安装 JDK(而不是从包系统)后,您需要将binJDK的目录添加到PATH. 在 Ubuntu 10.04 中执行此操作的最佳方法是编辑文件/etc/environment: sudo nano /etc/environment. 注销并重新登录,您应该能够运行 Java。

回答by Jeshurun

To run add-apt-repository, you need to install python-software-propertiesfirst. If you don't want to do this, you can:

要运行 add-apt-repository,您需要先安装python-software-properties。如果您不想这样做,您可以:

  1. Edit the sources.list file. sudo nano /etc/apt/sources.list
  2. Uncomment the lines deb http://archive.canonical.com/ubuntu lucid partnerand deb-src http://archive.canonical.com/ubuntu lucid partner(they are the second set from teh bottom)
  3. sudo apt-get update
  4. And finally, sudo apt-get install sun-java6-jdk.
  1. 编辑sources.list 文件。 sudo nano /etc/apt/sources.list
  2. 取消注释行deb http://archive.canonical.com/ubuntu lucid partnerdeb-src http://archive.canonical.com/ubuntu lucid partner(它们是从底部开始的第二组)
  3. sudo apt-get update
  4. 最后,sudo apt-get install sun-java6-jdk

回答by Synchro

Java is no longer in the partner repo. You can download the binaries directly from Oracle, but much easier is to use the the Web Upd8 PPA. Complete instructions are here.

Java 不再在合作伙伴存储库中。您可以直接从 Oracle 下载二进制文件,但使用 Web Upd8 PPA 要容易得多。完整说明在这里