因为版权和公司对开源软件的态度,Oracle Java SDK已经不再包含于Arch Linux默认的Repository。

不过对于有开发需要,又不得不使用Oracle公司的产品的民工们,还好有AUR中提供的相应支持,让我们能方便地用安装脚本来处理Oracle Java SDK的安装和配置。 

下面就简单地记录下的JDK的安装方法。 

安装环境如下:

Arch Linux 3.1.3
Oracle Java SDK 7 update 1


安装:

  • JRE

这里先安装JDK,虽然据说openjdk的jre也能兼容Oracle Java SDK,但还是有点担心它们的兼容性。 

先在Arch Linux AUR中找到JRE。 

制作安装包

$ wget --no-check-certificate -c https://aur.archlinux.org/packages/jr/jre/jre.tar.gz
$ tar -zxvf jre.tar.gz 
$ cd  jre
$ makepkg


处理依赖条件,开始安装

$ sudo pacman -S desktop-file-utils libxtst shared-mime-info xdg-utils
$ sudo pacman -U ./jre-7u1-1-i686.pkg.tar.xz
resolving dependencies... 
looking for inter-conflicts...

Targets (1): jre-7u1-1

Total Download Size: 0.00 MB
Total Installed Size: 91.42 MB

Proceed with installation? [Y/n]
(1/1) checking package integrity [######################] 100%
(1/1) checking for file conflicts [######################] 100%
(1/1) installing jre [######################] 100%

The jre package is licensed software.
You MUST read and agree to the license stored in
/usr/share/licenses/jre/LICENSE before using it.
Please relogin to include jre in your PATH.


Arch Linux中,Java SDK默认的安装位置是/opt/java

$ pwd 
/opt/java
$ ls
jre


至此,JRE成功安装。

  • JDK

JDK的安装过程与JRE类似。

$ wget -c --no-check-certificate https://aur.archlinux.org/packages/jd/jdk/jdk.tar.gz
$ tar -zxvf jdk.tar.gz
$ cd jdk
$ makepkg
$ sudo pacman -U ./jdk-7u1-1-i686.pkg.tar.xz 
Password:
resolving dependencies...
looking for inter-conflicts...

Targets (1): jdk-7u1-1

Total Download Size: 0.00 MB
Total Installed Size: 114.85 MB

Proceed with installation? [Y/n]
(1/1) checking package integrity [######################] 100%
(1/1) checking for file conflicts [######################] 100%
(1/1) installing jdk [######################] 100%
The jdk package is licensed software.
You MUST read and agree to the license stored in
/usr/share/licenses/jdk/LICENSE before using it.
Please relogin to include jdk in your PATH



配置:

 

安装之后打开/etc/environment文件编辑,添加如下内容:

#Java SDK 
#
CLASSPATH=.:/opt/java/lib
JAVA_HOME=/opt/java


添加之后就可以使用java和javac命令了

$ java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode)
$ javac -version
javac 1.7.0_01