java 可以将 `apt-get install` 用于 JDK 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1229494/
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
Can `apt-get install` be used for JDK?
提问by Eric Wilson
I've been using a linux machine for less than two weeks, so I am extremely new to Linux.
我使用 linux 机器不到两周,所以我对 Linux 非常陌生。
I'd also like to install the Java Developers Kit. How should this be done? Is there an apt-getcommand, or should I just click on the download button at Sun's website?
我还想安装 Java Developers Kit。这应该怎么做?是否有apt-get命令,或者我应该单击 Sun 网站上的下载按钮?
I'm sure there is more than one way to do this, and it probably doesn't matter much, but I was impressed with how smoothly apt-get installworked when installing PHP and MySQL, so if there is a rightway to do this, I'd like to know.
我确信有不止一种方法可以做到这一点,这可能并不重要,但我对apt-get install安装 PHP 和 MySQL 时的顺利工作印象深刻,所以如果有正确的方法来做到这一点,我'我想知道。
I'm using Ubuntu version 9.04
我正在使用 Ubuntu 9.04 版
采纳答案by kristianp
The Oracle JDK is no longer included in the Ubuntu repos. According to https://stackoverflow.com/a/15543636/192221, the following ppa can be used:
Oracle JDK 不再包含在 Ubuntu 存储库中。根据https://stackoverflow.com/a/15543636/192221,可以使用以下 ppa:
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java7-installer
If you have OpenJDK installed already, you might need to use
如果您已经安装了 OpenJDK,则可能需要使用
update-alternatives --config java
to use the Oracle Java by default.
默认使用 Oracle Java。
回答by Mehrdad Afshari
Yes, definitely it's the suggested way to install JDK on your Linux system (if available).
是的,这绝对是在 Linux 系统上安装 JDK 的建议方法(如果可用)。
On Ubuntu:
在 Ubuntu 上:
sudo apt-get install sun-java6-jdk
回答by Mr Shark
If you for some reason need to install the sun packages you can use the make-jpkg command to create a deb file and still have the files managed by apt/dpkg.
如果您出于某种原因需要安装 sun 软件包,您可以使用 make-jpkg 命令创建一个 deb 文件,并且这些文件仍然由 apt/dpkg 管理。
To do this:
去做这个:
sudo apt-get install java-package
fakeroot make-jpkg jre-1_5_0_06-linux-i586.bin
you will then have a .dpg file that you can install using for example gdebi
然后您将拥有一个 .dpg 文件,您可以使用例如 gdebi 安装该文件
gdebi-gtk jre.deb
Also note that you can have multiple JDKs installed and switch between them using update-alternatives:
另请注意,您可以安装多个 JDK 并使用 update-alternatives 在它们之间切换:
update-alternatives --config java
update-alternatives --config javac
and so on for other java related binaries, have a look in /etc/alternatives to find out which are available.
对于其他与 java 相关的二进制文件,请查看 /etc/alternatives 以了解哪些可用。
回答by Mr Shark
In Ubuntu 9.10 Karmic Koala apt-getand the Synaptic Software Managerboth install version 6.15.1of Sun Java and the JDK, which are now out of date, and an old version of Netbeans,, so don'tuse "sudo apt-get install" for these.
在 Ubuntu 9.10 Karmic Koala apt-get和Synaptic Software Manager 中都安装了 Sun Java 和 JDK 的6.15.1版本(现在已经过时)和旧版本的 Netbeans,所以不要使用“sudo apt-获取安装”为这些。
Go to the Sun Java download page http://www.java.com/en/download/manual.jsp
转至 Sun Java 下载页面 http://www.java.com/en/download/manual.jsp
Select the non-RPM 32-bit or 64-bit self extracting file, download it and check the file size of the downloaded file. Doesn't matter where you download it.
选择非RPM 32位或64位自解压文件,下载并查看下载文件的文件大小。在哪里下载都没有关系。
Click on the link to installation instructions for the corresponding file.
单击相应文件的安装说明链接。
An easier way to set executable permission is to right click on the file in the file browser (Nautilus) and click Properties, then on the Permissions tab, click the Execute checkbox.
设置可执行权限的一种更简单的方法是在文件浏览器 (Nautilus) 中右键单击文件并单击“属性”,然后在“权限”选项卡上单击“执行”复选框。
To test, open a new terminal and type:
要进行测试,请打开一个新终端并键入:
java -version
You should see Java version "1.6.0_18" etc.
您应该会看到 Java 版本“1.6.0_18”等。
If you don't, you probably need to add some lines, adjusted to suit your installation directories, to .bashrc and .bash_profile which are both hidden files in your home directory.
如果你不这样做,你可能需要添加一些行,调整到适合你的安装目录,到 .bashrc 和 .bash_profile ,它们都是你的主目录中的隐藏文件。
gedit .bashrc
Add the following:
添加以下内容:
export JAVA_HOME=/opt/java/64/jre1.6.0_18
export PATH=$PATH:$JAVA_HOME/bin
Then edit your .bash_profile file and insert the same lines at the end:
然后编辑您的 .bash_profile 文件并在末尾插入相同的行:
gedit .bash_profile
Open a new terminal window and test as above.
打开一个新的终端窗口并按上述方式进行测试。
If all went well, in the Applications menu > System Tools, you should now have the Sun Java Control Panel.
如果一切顺利,在应用程序菜单 > 系统工具中,您现在应该拥有 Sun Java 控制面板。
You can repeat a similar installation procedure for the JDK and Netbeans where you mark the downloaded .bin file as executable and then execute it from a terminal window in the directory you want to install into, such as /usr/local.
您可以为 JDK 和 Netbeans 重复类似的安装过程,将下载的 .bin 文件标记为可执行文件,然后从终端窗口中要安装到的目录(例如 /usr/local)中执行它。
After installing the JDK, add to your .bashrc and .bash_profile files a line similar to this:
安装 JDK 后,在 .bashrc 和 .bash_profile 文件中添加类似于以下内容的行:
export PATH=$PATH:/usr/local/jdk1.6.0_18/bin
Netbeans 6.8 seems to be able to set itself up ok without any editing and adds itself to the Applications Programming menu.
Netbeans 6.8 似乎无需任何编辑即可自行设置,并将自身添加到 Applications Programming 菜单中。
回答by Meredith L. Patterson
My Ubuntu box has sun-java5-jdkand sun-java6-jdkavailable.
我的Ubuntu箱具有sun-java5-jdk与sun-java6-jdk提供。
回答by Adam F
I am personally a linux mint person. However, I couldn't find this in my respitory:
我个人是一个 linux mint 人。但是,我在我的呼吸系统中找不到这个:
sudo apt-get install sun-java6-jdk
After poking around for a bit, I was able to get this to work.
在摸索了一会儿后,我能够让它发挥作用。
sudo apt-get install openjdk-6-jdk
Cheers.
干杯。
回答by lzrckt
I'm not sure Ubuntu 9.04. Is it openJDK? But in Ubuntu 9.10 It is openJDK. So It have many problem.
我不确定 Ubuntu 9.04。是openJDK吗?但是在 Ubuntu 9.10 中是 openJDK。所以它有很多问题。
You can do like this to remove and install sun java jdk
您可以这样做来删除和安装 sun java jdk
sudo apt-get remove openJDK* sudo apt-get install sun-java6*
sudo apt-get 删除 openJDK* sudo apt-get install sun-java6*

