歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 14.04 jdk安裝與配置

Ubuntu 14.04 jdk安裝與配置

日期:2017/2/28 13:54:34   编辑:Linux教程

(1)jdk安裝

需要在Ubuntu下使用Pycharm,但是Pycharm是用Java寫的,所以必須安裝jdk。安裝的方法很多,上官網找了適合Ubuntu的,給出下面的文檔:

============================================

Installation of the 64-bit JDK on Linux Platforms

This procedure installs the Java Development Kit (JDK) for 64-bit Linux, using an archive binary file (.tar.gz).

These instructions use the following file:

jdk-8uversion-linux-x64.tar.gz
  1. Download the file.

    Before the file can be downloaded, you must accept the license agreement. The archive binary can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

  2. Change directory to the location where you would like the JDK to be installed, then move the .tar.gz archive binary to the current directory.

  3. Unpack the tarball and install the JDK.

    % tar zxvf jdk-8uversion-linux-x64.tar.gz

    The Java Development Kit files are installed in a directory called jdk1.8.0_version in the current directory.

  4. Delete the .tar.gz file if you want to save disk space.

============================================

顯然有時候你會發現自己看官方的英文文檔要比上網去找教程好,網上的教程雖多,但有時候也雜亂,所以這時候還不如找官方的文檔看。鏈接可以看這裡:http://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html

完了之後,選擇把jdk解壓在/usr/lib/java目錄中,安裝即完成。

(2)配置環境變量

執行下面的命令:

1 echo "PATH=$PATH:/usr/lib/java/jdk1.8.0_65/bin" >> ~/.bashrc

使配置生效:

1 source ~./bashrc

輸入java:

1 2 3 4 5 6 xpleaf@leaf:~$ java 用法: java [-options] class [args...] (執行類) 或 java [-options] -jar jarfile [args...] (執行 jar 文件) ......................

比較簡單。

(3)更好的安裝與配置方法

當然前面的都要自己去動手,如果你覺得還是太麻煩了,那就采用在線的方式吧。這樣做還有一個好處,那就是不用你自己手動配置。

1.首先更新軟件源

sudo apt-get update

如果更新軟件源的時候總是出現問題,你可以考慮更改軟件源,只需要把/etc/source.list中的內容修改就可以了,至於哪個更新源比較好,看你所在的網絡環境。自己可以百度去找一些,建議用國內的。

2.安裝jdk

sudo apt-get install openjdk-8-jre

如果提示說沒有這個軟件,那就說明是軟件源的問題,把軟件源改掉吧。

3.輸入java

輸入java發現就有提示了,說明配置都已經幫我們做好了。

Ubuntu 14.04安裝JDK1.8.0_25與配置環境變量 http://www.linuxidc.com/Linux/2015-01/112030.htm

CentOS 搭建JDK環境 http://www.linuxidc.com/Linux/2015-06/118879.htm

Ubuntu 14.04安裝JDK1.8.0_25與配置環境變量 http://www.linuxidc.com/Linux/2015-01/112030.htm

Ubuntu 14.04 LTS安裝Oracle JDK 1.8 http://www.linuxidc.com/Linux/2014-11/109216.htm

CentOS6.3安裝JDK和環境配置 http://www.linuxidc.com/Linux/2012-09/70780.htm

Ubuntu 14.04 安裝 JDK8 http://www.linuxidc.com/Linux/2014-09/106218.htm

Ubuntu下安裝JDK圖文解析 http://www.linuxidc.com/Linux/2014-09/107291.htm

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved