2012. 5. 1. 09:01 Programming/Java
sun java 설치
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-bin sun-java6-jdk
sudo update-alternatives --config java
* another method
http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html
적당한 bin 파일 받음.
chmod 755 jdk-x.x.x.x.bin
./jdk-x.x.x.bin
ln -s /home/xxxx/jdk-x.x.x.x/ /usr/local/java
path 설정
vi .bashrc
PATH =
JAVA_HOME =
export path =
Installing Oracle Sun Java (JDK) and setting JAVA_HOME in Ubuntu (Linux)
This post is not only for people who are new to Linux or Java but also quick notes for me to setup my environment next time I install my system or setup a virtual machine.
Installing OpenJDK can be very simple but not Oracle JDK. You can use one of the two following commands (depending on which version you which to install) to setup OpenJDK in your linux environment.
sudo apt-get install openjdk-6-jdk
or
sudo apt-get install openjdk-7-jdk
But I have always used Oracle Sun JDK for my development. While Oracle JDK (earlier Sun JDK) is under the Binary Code License (earlier Sun License), OpenJDK is under GPL with a linking exception. From JDK version 7, Oracle has planned to support OpenJDK and withdraw the Operating System Distributor License for Java. This has resulted in a withdrawal of Oracle JDK from the repositories of Linux distributions. Therefore you can’t just use apt-get to install Oracle JDK.
Here is the stackoverflow link to help you choose between the Oracle JDK or OpenJDK.
But users who prefer to use the Oracle JDK binaries over OpenJDK builds packaged in their Linux distributions of choice can of course download the package fromhttp://oracle.com/java under the same terms as users on other platforms. Here is the direct link to JavaSE downloads.
Coming the point I have downloaded JDK 7 (update 4) for Linux x86 (32-bit) – file:jdk-7u4-linux-i586.tar.gz
Step 1: After downloading the file open the terminal and navigate to the file
tar -xf jdk-7u4-linux-i586.tar.gz
This will extract and create a jdk folder at your current path.
Step 2: Create a location to keep your new JDK . I prefer and usually use /usr/lib/jvm/
You may need root permission to create the /usr/lib/jvm (hence use sudo).
sudo mkdir /usr/lib/jvm
Step 3: Move the extracted jdk folder to /usr/lib/jvm/
sudo mv jdk1.7.0_04 /usr/lib/jvm/
Step 4: Now we have to setup our system to use refer to our new jdk
sudo update-alternatives --install "/usr/bin/java" "java" \
"/usr/lib/jvm/jdk1.7.0_04/bin/java" 1
sudo update-alternatives --config java
And also register Firefox Java Plugin
sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" \
"mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.7.0_04/jre/lib/i386/libnpjp2.so" 1
sudo update-alternatives --config mozilla-javaplugin.so
ALL DONE. You can test your java install by
java -version
Here is a small screen capture of what happened on my screen when I went through above steps
Finally if you need to add JAVA_HOME variable, you can do so by adding it to the.bashrc file in your home directory
Open .bashrc file using an editor. If you use VI then
vi ~/.bashrc
and add the following 2 lines in your .bashrc file.
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_04/
export JAVA_HOME
There may be other ways to install, but this is what I have followed always.
Cheers