Sunday, August 9, 2009

HOWTO : Setup Java Development Environment on Ubuntu

Packages to be installed: JDK 6, JRE 6, Eclipse (Ganymede – 3.4.2), Tomcat 6

A. Install JDK and JRE:

1. Open the terminal
2. Type sudo apt-get install sun-java6-jdk sun-java6-jre

It will install the JDK and JRE on your system.
Now you can check the version by typing javac -version

3. Set the $JAVA_HOME
export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.10"


B. Install Eclipse:


1. Download the latest release of the Eclipse (In my case that was Eclipse Ganymede 3.4.2) from eclipse website. http://www.eclipse.org/downloads/packages/release/ganymede/sr2

2. Now extract the .tar.gz in your home directory
tar -xzvf eclipse-jee-ganymede-SR2-linux-gtk.tar.gz

3. To check the Eclipse is opening or not go to the /eclipse directory
cd eclipse

4. Now type the command ./eclipse
The eclipse will open. Now close the eclipse for the time being.


C. Time for Tomcat 6

1. download the copy of Tomcat 6 from apache website http://tomcat.apache.org/download-60.cgi .... it should be a .tar.gz under Core (in my case that was apache-tomcat-6.0.20.tar.gz)

2. Extract the .tar.gz in your home directory
tar -xzvf apache-tomcat-6.0.20.tar.gz

3. Now we have to move it to the /usr/local/tomcat directory. Type this command to do that:
sudo mv apache-tomcat-6.0.20 /usr/local/tomcat

4. Setup Tomcat to Boot on Startup
a) sudo nano /etc/init.d/tomcat

b) Copy and paste this script, making sure to either configure or remove CATALINA_BASE and CATALINA_OPTS:

------------------------------------------------------
#!/bin/bash

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export CATALINA_BASE=/path/to/catalina/base
export CATALINA_OPTS="-server -Xmx512m"
case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac
exit 0

------------------------------------------------------

c) Press Ctrl+X to exit, and answer Yes to save.


5. Now make the above script executable, and install it as a startup script:

sudo chmod 755 /etc/init.d/tomcat
sudo update-rc.d tomcat defaults


6. Type sudo /etc/init.d/tomcat start and your tomcat will be up.


So, your Java Environment is ready to rock with your code!!!!!

2 comments:

  1. Few more tools apart from what is mentioned above -
    http://www.skillassert.com/tutorial/29_Java_Developer_Guide_for_Windows_to_Ubuntu_migration

    ReplyDelete
  2. Good post. I wrote something similar in the post, "Getting NetBeans ready for work on Ubuntu".

    From my opinion, Ubuntu is a much better "Java" development platform than other os (read windows)!.

    ReplyDelete