Installing Eclipse (with PDT) – Ganymede on 64 bit Ubuntu

Eclipse with PDT is an awesome platform for PHP development – It offers (for free) all the bells and whistles of a modern IDE including code formatting, highlighting and code completion (AKA intellisense)!

Installing Eclipse(Ganymede) on a 64 bit linux os is slightly convoluted as there is no deb package available and it requires quite a bit of manual setup. Hopefully this process will get simpler as 64 bit gets into the mainstream.

1. Setting up JRE (Java Runtime Environment) : Eclipse is developed using Java and so requires the JRE in order to run on your computer. You can get the latest version of JRE from http://java.com/en/download/manual.jsp.

Click on the “Linux x64” link (not RPM, not Self Extracting) and save it on your desktop (as of this writing, the most current version is : jre-6u13-linux-x64.bin). Now, this is a non-system,  binary file and therefore may be installed in the /opt folder in accordance with the Filesystem Hierarchy Standard. Open up a terminal session:

cd /opt
sudo mkdir java
cd java
sudo mkdir 64
sudo mv ~/Desktop/jre-6u13-linux-x64.bin /opt/java/64

The above commands create the /opt/java/64 folder and move the jre binary into that folder.

Finally, execute the binary file:

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

If all goes well, you should have a directory named jre1.6.0_13 in /opt/java/64

Now, all that is left to be done to tell the system to use this newly installed JRE.

Debian provides a brilliant feature named “update-alternatives” that allows various versions of software to coexist on the system. We will make use of this to reference our newly installed java runtime.

update-alternatives works by providing indirections/symlinks at various levels.. For ex:

/usr/bin/java->/etc/alternatives/java->the actual java runtime directory

We do not do this linking manually. Instead, we use the “update-alternatives” command. First, you need to check how many alternatives your ubuntu installation currently has so you can choose the number/id of the newly installed runtime. You can do this by typing:

sudo update-alternatives –config java

The command to install our jre as alternative ‘1’ is (Note the number 1 at the end of the command):

sudo update-alternatives –install “/usr/bin/java” “java” “/opt/java/64/jre1.6.0_13/bin/java” 1

Now, you can make alternative 1 as the default Java runtime by typing:

sudo update-alternatives –config java

and selecting 1

Excellent.. now, to double check everything is as it should be, in a Terminal run:

java -version

You should see

java version “1.6.0_13”

Tip: Uninstalling the java runtime is super easy too! All that is required is to delete the folder delete the folder (java).. The next time you (or a program) request java, the system will try to find the java runtime by probing the alternatives, not find it, and get rid of the symlinks automatically.. could not be easier!

2. Installing 64 bit Eclipse: First, download the 64 bit version of Eclipse IDE for Java Developers onto your desktop (we will install the eclipse framework first and then add on PDT)

After download, extract and as with the Java install , move the files to /opt

cd ~/Desktop
tar -zxvf eclipse-java-ganymede-SR2-linux-gtk-x86_64.tar.gz
sudo mv eclipse /opt

Do not run eclipse just yet.. The next few steps involve adjusting the permissions so that you will not require to use sudo in order to run eclipse:

cd /opt
sudo chown -R root:root eclipse
sudo chmod -R +r eclipse

The eclipse folder (and subfolders) are now owned by root and are readable by all. Next create an eclipse executable in /usr/bin so that it will be in the “executable path”

sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse
sudo gedit /usr/bin/eclipse

Add the following contents to the file /usr/bin/eclipse:

#!/bin/sh
export ECLIPSE_HOME=”/opt/eclipse”
$ECLIPSE_HOME/eclipse $*

Next create a desktop launcher to execute eclipse (right click on desktop->new->launcher.. enter “eclipse” as the command)

You can even setup the launcher with a fancy icon!

3. Installing PDT (PHP Development Tools)

Go ahead and launch eclipse.. You will be prompted to select a workspace. Once Eclipse has started, go to Help -> Software Updates. Click on the “Available Software” tab. Click the “Manage Sites” button, followed by “Add” once the Site Manager appears. Enter:

http://download.eclipse.org/tools/pdt/updates/2.0/interim/

and hit OK. Click “install” and follow the prompts. Once installed, Eclipse will prompt to restart the application. Accept, restart, and enjoy a shiny new PHP IDE!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s