Linux---jdk1.6

来源:互联网 发布:金融信用基础数据库 编辑:程序博客网 时间:2024/06/05 18:44

The reason why Oracle's Java implementation is not supported or distributed by Ubuntu already discussedhere.

The basic idea is that Oracle's Java Se will not be included in any official Ubuntu repo due to license problems created by Oracle.

That does not stop you from installing Oracle's JDK from a PPA or from the official package files from the Oracle's site.

This guide describes how-to download, install and make javajavac and javaws from Oracle available to use in your system.

How to install Oracle Java JDK6u30 on Ubuntu 11.10

(should work with any other version downloaded from Oracle)

  • Download Sun/Oracle Java JDK

Download Sun/Oracle Java JDK or JRE from here (current version is JDK 6 Update 30)http://www.oracle.com/technetwork/java/javase/downloads/index.html.

Note: Select any of the Linux x86 or Linux x64 bin packages (example jdk-6u30-linux-i586.bin,jdk-6u30-linux-x64.bin) depending on your system and preference.

  • Make the file executable

chmod +x /path/to/file/jdk-6u30-linux-*.bin

  • Run Sun/Oracle Java JDK binary and delete it

/path/to/binary/jdk-6u30-linux-*.bin && rm /path/to/binary/jdk-6u30-linux-*.bin

There will be a newly created folder on the same path with the extracted files

  • Move the folder to a system wide path and give it a more identifiable name

mkdir -p /usr/lib/jvm

cd /path/to/binary/

mv /path/to/binary/jdk1.6.0_30 /path/to/binary/java-6-oracle && mv /path/to/binary/java-6-oracle /usr/lib/jvm/

 

  • Add the new version of java, javac and javaws as an system alternative and give it priority 1

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-6-oracle/bin/java" 1

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-6-oracle/bin/javac" 1

sudo update-alternatives --install "/usr/bin/javaws" "java" "/usr/lib/jvm/java-6-oracle/bin/javaws" 1

  • Select the new alternatives to be used

sudo update-alternatives --config java

Select you created java alternative

sudo update-alternatives --config javac

Select you new created javac alternative

sudo update-alternatives --config javac

Select you new created javaws alternative

  • Test your newly added java and javac

java -version should return

java version "1.6.0_30"

Java(TM) SE Runtime Environment (build 1.6.0_30-b12)

Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing)

and javac -version should return

javac 1.6.0_30

  • Update system paths

Open /etc/profile with you favorite text editor, ie

gksudo gedit /etc/profile

Navigate to the end of the file and add these contents

JAVA_HOME=/usr/lib/jvm/java-6-oracle

PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

export JAVA_HOME

export JAVA_BIN

export PATH

Reload your system wide PATH /etc/profile with

. /etc/profile

That is for Oracle's JDK, javajavac and javaws should be running from the Oracle's package.

The version here installed can be updated easily by copying the new version over the currently installed files. Just extract the package and copy over the new one over the one that is currently installed.

You might want to check /etc/alternatives for links to older installs of JRE - there are many tools that might not be found on your system after a manual install like this.

Also the Variable JAVA_BIN should have some content, but I think it is not needed at all...

 

 

 

 

 

Due to license issues Ubuntu will no longer distribute Oracle's JDK and JRE. Also previous versions supplied on PPAs suffer from security issues are are not recommended to be installed on any Ubuntu system.

There are no more supported java releases from Ubuntu - Ubuntu officially supports OpenJDK and OpenJRE implementation of Java which is the base for Oracle's own implementation.

To install the OpenJDK & OpenJRE refer to this Q&A.

The instructions below provide a guide to install the official Oracle JDK 6. You will need to regularly update this manually to ensure your installation maintains recommended security and stability fixes.

Install the Oracle JDK 6

Oracle themselves have the official guide to install their JDK - below is based upon those instructions.

  • Download the 32bit or 64bit Linux "compressed binary file" - it has a ".bin" file extension
  • Give it permissions to execute and extract it

    chmod a+x [version]-linux-i586.bin

    ./[version]-linux-i586.bin

During installation it will ask you to register - press ENTER. Firefox will open with the registration page. Registration is optional.

JDK 6 package is extracted into ./jdk1.6.0_x directory, for example ./jdk1.6.0_30.

Lets rename it:

mv jdk1.6.0_30 java-6-oracle

  • Now move the JDK 6 directory to /usr/lib

sudo mkdir /usr/lib/jvm

sudo mv java-6-oracle /usr/lib/jvm

switch to Oracle JDK 6

webupd8.googlecode.com hosts a nice-easy script to help with this.

wget http://webupd8.googlecode.com/files/update-java-0.5b

chmod +x update-java-0.5b

sudo ./update-java-0.5b

An alternative to this is to use the webupd8 ppa and the update-java package.

Finally test the switch has been successful:

java -version

javac -version

These should display the oracle version installed - 1.6.0_30

 

 

 

Since Oracle Java has been removed from the repository, you will have to add a new repository like mentioned in this article. The repository described there has also packages for Oneiric.

Excerpt from the description:

Open up a terminal window under Application -> Accessories -> Terminal, adding the ppa > by:

sudo add-apt-repository ppa:ferramroberto/java

sudo apt-get update

Then, install java jre:

sudo apt-get install sun-java6-jre sun-java6-jre-plugin

Install Jdk by the command:

sudo apt-get install sun-java6-jdk

 

 

 

I expect, that the ppa of ferramroberto might not be working in the future, because repackaging of java is not allowed any more. Unfortunately what is not allowed for canonical is also not allowed for any other packager. So the solution mentioned above might be the only way (which is basically a wrapper for update-alternatives!):

http://www.webupd8.org/2011/09/how-to-install-oracle-java-7-jdk-in.html

It is generally a good idea, to get an oracle account and get the java newsletter to be informed about software updates until a solution comes along the way for us ubuntu users to be informed about updates.

原创粉丝点击