Thursday, October 31, 2013

Installing Java JRE / Java JDK in Debian Linux

This method installs Java and JDK onto your on a Debian Linux system.  The example is for version 7u21, but you can use it for newer versions (just make sure to change the code to reflect the version you are installing).  

Pre-Install Procedures:

# apt-get purge openjdk-\*

# mkdir -p /usr/local/java

This purges the open Java from your system.


Install Procedures:

Download Java and JDK from the Java website

Unpack the files into the /usr/local/java folder


Post-Install Procedures:

The following edits your profile:
# echo "JAVA_HOME=/usr/local/java/jdk1.7.0_21" >> /etc/profile
# echo "PATH=$PATH:$HOME/bin:$JAVA_HOME/bin" >> /etc/profile
# echo "JRE_HOME=/usr/local/java/jre1.7.0_21" >> /etc/profile
# echo "PATH=$PATH:$HOME/bin:$JRE_HOME/bin" >> /etc/profile
# echo "export JAVA_HOME" >> /etc/profile
# echo "export JRE_HOME" >> /etc/profile
# echo "export PATH" >> /etc/profile


This Informs sytem where Java is
# update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_21/bin/java" 1

# update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_21/bin/javac" 1

# update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0_21/bin/javaws" 1


Updates Java as default Java
# update-alternatives --set java /usr/local/java/jre1.7.0_21/bin/java

# update-alternatives --set javac /usr/local/java/jdk1.7.0_21/bin/javac

# update-alternatives --set javaws /usr/local/java/jre1.7.0_21/bin/javaws


Optional Java Browser Plugins: 
Installs plugin in Google Chrome
# mkdir -p /opt/google/chrome/plugins

# ln -s /usr/local/java/jre1.7.0_21/lib/amd64/libnpjp2.so /opt/google/chrome/plugins

Installs in Firefox
# mkdir -p /usr/lib/mozilla/plugins

# ln -s /usr/local/java/jre1.7.0_21/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins


You should now have Java on your system.  
You can test by typing java -version at the command line.

If you are lazy, in a hurry or just want to do it the easy way:

https://dl.dropboxusercontent.com/u/62401040/Java/javapkg_1.7.0-21-b11_amd64.deb

This package does all the above.

No comments:

Post a Comment