For using most of the enterprise technologies based on Java, you generally need at least the following components installed and configured on your system:
- Sun Java SE (or EE) SDK
- A command line build tool like Ant or Maven
- A Java application server/container like Tomcat, Jetty, Glassfish, JBoss etc.
Based on which Java based technology/framework you want to use, you may need to install further dependencies. Even though you may not need all the three components mentioned above to be able to work with all Java technologies, I found myself installing them way too many times when compared to any other Java component that I wanted a place to document the installation process of these three components specifically, if only to refer to this post from other Java tutorials in future.
Installing OpenJDK/Sun Java SE 6, Apache Maven 2 and Tomcat 5 on Fedora GNU/Linux
Installing Java SE 6
You can’t install Sun’s JDK directly from the Fedora repositories, you have the following two choices:
- Use OpenJDK that comes installed by default in Fedora 9(if not, you can install it with a simple ‘yum install java-1.6.0-openjdk’ command; or first search for the exact package name using ‘yum search jdk’). If you want to go with Fedora’s OpenJDK then you don’t have to do anything else, except perhaps set JAVA_HOME environment variable to OpenJDK installation path in your profile file.
- Install Sun’s latest JDK by manually downloading the binaries from Sun’s website. If you are very specific about using Sun’s official JDK only, then you first have to un-install OpenJDK that is installed by default in Fedora 9. Then you need to and run the installer. (Download the Java EE SDK if you want to install the enterprise edition.) Assuming you have downloaded Sun JDK binary and saved it in your home directory under a name like jdk-6u7-linux-i586.bin, run the following commands to complete the installation:
# yum remove java-1.6.0-openjdk java-1.6.0-openjdk-plugin
# yum install compat-libstdc++-33 compat-libstdc++-296
# cd ~ & chmod +x jdk-6u7-linux-i586.bin
# ./jdk-6u7-linux-i586.bin
# javac -version
javac 1.6.0_07As a final step, add the following line to your profile file(e.g. .bash_profile) to set the JAVA_HOME environment variable to the path where you have installed Sun JDK:
export JAVA_HOME /opt/jre/jdk
Make JAVA_HOME point to OpenJDK installation path if you are using OpenJDK.
Installing Apache Maven2
Apache Maven 2 can be installed using yum command:
# mvn ––version
Maven version 2.0.4
# yum remove maven2
Installing Maven 2 on Fedora 9 using the yum package manager gave me the old 2.0.4 version, so I removed it and decided to install Maven manually. To manually download and extract Maven 2 archive on Fedora 9, follow these instructions:
- Download the latest stable version of Apache Maven 2 archive from its .
- Extract it to your home directory and rename the directory to ‘maven2′
# tar xjvf apache-maven-2.0.9-bin.tar.bz2
# mv apache-maven-2.0.9-bin maven2 - Add the following line to your profile file(e.g. .bash_profile or /etc/profile) to set maven2 executables in system path:
export PATH=$PATH:$HOME/maven2/bin
- Confirm if Maven 2 is installed and configured correctly:
# source .bash_profile
# mvn ––version
Maven version 2.0.9
Java version 1.5.0
Installing Tomcat 5 and Jetty
You can finally install tomcat and jetty servers using yum command:
The installation procedure on other GNU/Linux distributions should be on similar lines using their respective package managers and I will try to post the procedure for Ubuntu, Gentoo, openSuse and Mandriva distributions in the near future.
Testing the installation
To test the above installation, see my next post(to be published), “Hello, World” Java Web Application using Java SE 6 + Tomcat 5.5 + Maven 2.”
Your instructions are confusing to me. If you install the jdk-6u7-linux-i586.bin, then why would you
expect to see java version 1.5? Aren’t you installing java 6 update 7?
Comment by Lee — October 12, 2008 @
Lee, by mistake I copied and pasted the output of ‘java -version’ command instead of ‘javac -version’ output(also, before switching to Sun’s JRE using ‘alternatives’ command). I have updated the post to correct the mistake, thanks for pointing it out.
Comment by — October 18, 2008 @