Aug 02
1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 4.67 out of 5)
Loading ... Loading ...

Java JRE LogoI wanted the latest version of Sun’s JRE installed on my system, and to have it set up as the default Java Runtime Environment whenever I ran a Java executable, or Jar file. It’s actually a pretty easy process, so this is a relatively short tutorial, but I’ll cover both the 32 bit and 64 bit installations, since aside from differences in file names, the set up is identical.

Installing JRE

First, decide on which architecture will be installed, and download the relevant file from the main Java website. At the time of writing, 1.6.0 u7 can be downloaded from the following: 32 bit, and 64 bit. I wanted to install the x64 version, and so downloaded jre-6u7-linux-x64.bin to my Desktop. I also wanted to install it in its own directory in /opt, and so created a directory for it to sit in:

cd /opt
sudo mkdir java

I was also experimenting with the 32 and 64 bit versions, so made two extra directories within java:

cd java
sudo mkdir 32 64

I then copied the relevant file(s) to the respective directories, and made them executable:

32 bit:

sudo cp ~/Desktop/jre-6u7-linux-i586.bin /opt/java/32
sudo chmod 755 /opt/java/32/jre-6u7-linux-i586.bin

64 bit:

sudo cp ~/Desktop/jre-6u7-linux-x64.bin /opt/java/64
sido chmod 755 /opt/java/64/jre-6u7-linux-x64.bin

The final part of the installation simply involves executing the binary file:

32 bit:

cd /opt/java/32
sudo ./jre-6u7-linux-i586.bin

64 bit:

cd /opt/java/64
sudo ./jre-6u7-linux-x64.bin

Regardless of architecture, this should create a sub directory called jre1.6.0_07.

Setting JRE 1.6.0 u7 as Default

The process simply involves telling the system that there is an alternative Java binary available, and to use this binary to execute an “java” commands:

32 bit:

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/32/jre1.6.0_07/bin/java" 1
sudo update-alternatives --set java /opt/java/32/jre1.6.0_07/bin/java

64 bit:

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.6.0_07/bin/java" 1
sudo update-alternatives --set java /opt/java/64/jre1.6.0_07/bin/java

Follwing the second command, there should be output to the terminal something along the lines of:

Using '/opt/java/32/jre1.6.0_07/bin/java' to provide 'java'.

or,

Using '/opt/java/64/jre1.6.0_07/bin/java' to provide 'java'.

depending on the architecture installed. That’s it. Now every time “java” is run, either explicitly from the Terminal, or via a Java executable (such as the Eclipse IDE), Ubuntu will use the newly installed /opt/java/64/jre1.6.0_07/bin/java binary as opposed to the binary installed by default. Simple, eh?

written by Hodge \\ tags: ,

Feb 29
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Eclipse SDKUpdate 12/04/08: I have now successfully installed the x64 version of Eclipse - see 64 Bit Eclipse: Linux Installation, including PDT, WTP (WST), ATF, and MySQL (SQL Explorer Plugin) for a step by step guide, or continue reading this article if you want to install the 32 bit version.

32 Bit installation

I went through several different methods of installing the Eclipse IDE on my Ubuntu system. I tried the obvious first - installing via the Synaptic Package Manager, but found it a bit of a pain to install any plugin packages I downloaded (I also use WST and SqlExplorer in addition to PDT). So, I uninstalled, then tried the 64 Bit version of the SDK (which at the time was pretty buggy, and unstable), in the hope that I’d be able to plug in a 64 Bit version of the PDT, which I soon found doesn’t exist yet! So, I finally settled for installing the 32 Bit version of Eclipse PDT, which enabled me to install the plugins too.

In order to install and run this successfully, I first downloaded the 32 Bit Java Runtime Environment installer “Linux (self-extracting file)” from http://www.java.com/en/download/linux_manual.jsp (or direct link to the file), and saved the jre-6u3-linux-i586.bin to my desktop.

Once the file downloaded, I opened up a Terminal (Applications -> Accessories -> Terminal), and typed

cd /usr/java

(if the java directory doesn’t exist, it need to be created:

sudo mkdir /usr/java
cd /usr/java

I also wanted a 64 bit version of the JRE installing, so within the /usr/java directory, created two more sub directories:

sudo mkdir 32
sudo mkdir 64

then copied the newly downloaded JRE installation file from the desktop to the /usr/java/32 directory, and made the file executable:

cd 32
sudo mv ~/Desktop/jre-6u3-linux-i586.bin /usr/java/32/jre-6u3-linux-i586.bin
sudo chmod a+x jre-6u3-linux-i586.bin

then execute the binary:

sudo ./jre-6u3-linux-i586.bin

Accept the terms, and so on and so forth… When it says “Done”, it’s, well, done!

ls

should return:

jre1.6.0_03

Note: If you download a newer version of JRE, then you’ll need to change the above commands containing “jre-6u3-linux-i586.bin” to “jre-6u<version>-linux-i586.bin” where <version> is 3, 4, 5 etc.!

Now for Eclipse. I downloaded the latest version from http://download.eclipse.org/tools/pdt/downloads/ (the current stable version is R20080103) - I click on the link for the latest release, and downloaded the pdt-all-in-one-R20080103-linux-gtk.tar.gz file to the desktop. Once it finished, I went back to the terminal, and entered the /opt directory, moved the Eclipse package to the /opt directory, and extracted the new files:

cd /opt
sudo mv ~/Desktop/pdt-all-in-one-R20080103-linux-gtk.tar.gz /opt
sudo tar -zxvf pdt-all-in-one-R20080103-linux-gtk.tar.gz

This extracts the Eclipse IDE into a directory called, oddly enough, “eclipse”. However, I’m experimenting with the 64 bit version too, so I changed the directory name to eclipse32:

sudo mv eclipse eclipse32

As it was, Eclipse wouldn’t run, since it doesn’t know where to find the JRE I’d just installed, so, I had to create a small shell script in order for it to run correctly:

cd eclipse32
gksu gedit eclipse.sh

This opened up a text editor, with a blank file called “eclipse.sh”. The shell script is:

#!/bin/bash
PATH=/usr/java/32/jre1.6.0_03/bin:$PATH
/opt/eclipse32/eclipse

PATH=/usr/java/32/jre1.6.0_03/bin:$PATH should point to the bin directory of the previously installed.

The script also needed to be executable:

sudo chmod 755 eclipse.sh

and I also changed the ownership of all the files and directories to my username:

sudo chown -R username:group *

That was pretty much it - I could run Eclipse by opening a Terminal window and running

cd /opt/eclipse32
./eclipse.sh

which got a little tiresome after the first time, so I created a menu item (System -> Preferences -> Main Menu) which pointed to /opt/eclipse32/eclipse.sh, and even included the png Eclipse logo for the icon :)

Any plugins can be downloaded, and extracted into the relevant directories - or, installed by the Eclipse Update Manager.

I’ve recently written a post on “Eclipse PDT and MySQL - SQL Explorer Plugin“, for anyone who needs to set up MySQL connections in Eclipse.

written by Hodge \\ tags: , , , , , , ,

Webloogle Blog Directory