2013. 6. 3. 23:27

Ubuntu 12.04 LTS에 java6 설치하기

다른 사이트에서 참고하여 올린다. 매번 까먹는다.

Ubuntu 12.04 is my primary OS, however, there doesn’t appear to be many guides on installing the Sun/Oracle JDK on Ubuntu.

In case someone else finds it useful, here’s what I did on my 64 bit Ubuntu 12.04 install:

1. Download the Java SE Development Kit 6 Update 38 for Linux x64 from http://www.oracle.com/technetwork/java/javase/downloads/jdk6u38-downloads-1877406.html (The filename should be jdk-6u38-linux-x64.bin and NOT jdk-6u38-linux-x64.rpm.bin)

2. Make the file executable: chmod +x jdk-6u38-linux-x64.bin

3. Extract the file ./jdk-6u32-linux-x64.bin

4. Create a directory called jvm in /usr/lib: sudo mkdir /usr/lib/jvm

5. Move the extracted JDK directory into /usr/lib/jvm: sudo mv jdk1.6.0_38 /usr/lib/jvm/jdk1.6.0_38

6. Make it the default JDK in the system:

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_38/bin/javac 1

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_38/bin/java 1

sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_38/bin/javaws 1

sudo update-alternatives --config javac

sudo update-alternatives --cconfig javaws

sudo update-alternatives --cconfig java


If you want, you can add the JAVA_HOME environment variable to point to your new JDK installation as:

export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_38/

and now you can put the JDK binaries like java, javac etc. as:

export PATH=$PATH:$JAVA_HOME/bin

Sticking those two statements in your .bashrc would ensure they always stay in your path across.

Edit: You can also enable the Java plugin for Chrome and Firefox as:

sudo ln -s /usr/lib/jvm/jdk1.6.0_38/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/libnpjp2.so


*** 참, 전체에 적용하려면, .bashrc 대신에, /etc/bash.bashrc 에 넣으면 끝.