0

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...

1
  • Any particular reason you don't want to use apt-get? Commented Dec 9, 2012 at 19:55

4 Answers 4

1

-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.

Sign up to request clarification or add additional context in comments.

8 Comments

How can I make it reload automatically? You think i should export it in the ~/.bashrc ? I am confused, then will it be accessible by all users?
This is really a "how do I configure my Unix environment" question. The ~/.bashrc allows you to change your default settings. There is an /etc/profile.d/ directory for scriptlets to add configuration for programs. This is where you can add java for all users. You might want to add your ide, and/or mvn there as well.
I just created an script and called it loadjava.sh Inside it i typed export JAVA_HOME="/usr/local/java/jdk1.6.0_37" and export PATH=$PATH:/usr/local/java/jdk1.6.0.37/bin Following your advice i added it into /etc/profile.d/ now every time i boot it is loaded and 'java -version' works fine. Just one more little question, do you think will i need to give all permiions to that script with chmod 777, or is no needed? Thanks for the useful answer.
As you ran the install as root, the permissions should be correct. 777 is a bad idea because it means anyone can change it to give themselves access to the account which runs it.
Ok i thought one was using for defining and the other for exporting, but i see, it is enough just enough to have does export commands in the script inside that folder.
|
1

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

JDK Installation - Ubuntu

Comments

0

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.