javing
javing

Reputation: 12423

Java not visible when using oracle self extracting installer for ubuntu

I want to install the oracle jdk 6 in ubuntu for all users using the self extracting installer at oracles website (jdk-6u37-linux-x64.bin)

This is what i do step by step:

1- Download the jdk-6u37-linux-x64.bin

2- Create a folder in the unix system resources and move the downloaded file there

sudo mkdir -p /usr/local/java

sudo mv /home/sfrj/Downloads/jdk-6u37-linux-x64.bin /usr/local/java

3- Make the file executable

sudo chmod 700 jdk-6u37-linux-x64.bin

4. Execute the installer

sudo ./jdk-6u37-linux-x64.bin

5. Remove the installer(Don't need it anymore)

sudo rm jdk-6u37-linux-x64.bin

6. Create a symbolic link

sudo ln -s jdk1.6.0_37 /usr/local/java/latest

7. Edit the file /etc/environment

JAVA_HOME="/usr/local/java/jdk1.6.0_37"
JRE_HOME="/usr/local/java/jdk1.6.0_37/jre"
PATH="/usr/local/java/jdk1.6.0_37/bin:\/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

8. Reload the environment file

source /etc/environment

So far so good, after all that and without closing the terminal I type: java -version and I see this:

java version "1.6.0_37" Java(TM) SE Runtime Environment (build 1.6.0_37-b06) Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)

The problem is, when close the terminal, open it again and type the command java -version again, I see this:

The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.6-jre-headless
 * gcj-4.7-jre-headless
 * openjdk-7-jre-headless
 * openjdk-6-jre-headless
Try: sudo apt-get install <selected package>

I am confused:

-Why is this?

-Did I install the jdk correctly?

-What is missing?

I want to install it this way, without using apt-get, so please don't answer to me use apt-get install...

Upvotes: 0

Views: 1524

Answers (4)

psabbate
psabbate

Reputation: 777

This is my online guide. There are a few differences, and it works for me.

JDK Installation - Ubuntu

Upvotes: 1

BillRobertson42
BillRobertson42

Reputation: 12883

These scripts will help you install sun's jdk on Ubuntu. Works great.

Upvotes: 0

Drunix
Drunix

Reputation: 3343

Debian style linux distros have the alternative mechanism for this kind of problems. They link /usr/bin/java to /etc/java which in turn is linked to the correct binary.

sudo update-alternatives --install /usr/bin/java java /usr/local/java/jdk1.6.0_37/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/local/java/jdk1.6.0_37/bin/javac 1
sudo update-alternatives --install /usr/bin/javaws java /usr/local/java/jdk1.6.0_37/bin/javaws" 1
sudo update-alternatives --install /usr/bin/jar jar /usr/local/java/jdk1.6.0_37/bin/jar 1
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config jar
sudo update-alternatives --config javaws

You may want to repeat this for the other commands like wsimport. Have a look at https://help.ubuntu.com/community/Java. There are also other options listed like using a PPA, but if you strictly don't want to use apt-get, this is not an option.

Upvotes: 0

Peter Lawrey
Peter Lawrey

Reputation: 533780

-Why is this?

You are not setting your path in a way which is reloaded automatically.

-Did I install the jdk correctly?

There is two ways of installing it. For the self unpacking version this is correct.

-What is missing?

Your environment is not set correctly.

Upvotes: 1

Related Questions