Howto Install Java, Tomcat, Netbeans
Installing Java
The installation will take place via the terminal (go to the menu select Applications->Accessories->Terminal)
NB: Do NOT Log in as root
Once the terminal loads, we can start.
Add the repository by issuing the following line to the terminal;
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
Then run an update of ubuntu
sudo apt-get update
Now we install the required packages
sudo apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre sun-java6-plugin sun-java6-fonts
Test that Java is installed and what version by issuing the following command
java -version
SET JAVA_HOME
Get the path to JDK/JRE install folder. Test if JAVA_HOME is set
echo $JAVA_HOME
If set, it could be something like /usr/lib/jvm/java-X.Y.Z-sun-X.Y.Z
At the command prompt, type (NOTE YOU NEED TO GIVE THE PATH TO YOUR JAVA, the one below is just in my case and may differ)
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.21/
If interested, you could also install the following as explained below;
1. Spring
2. Netbeans (You definately need this)
3. Tomcat
Spring Framework
Spring is a popular and widely deployed open source framework that helps developers build high quality applications faster. Spring provides a consistent programming and configuration model that is well understood and used by millions of developers worldwide (Source:springsource.com).
Go to http://www.springsource.com/downloads and download
Download SpringSource Tool Suite – pick the .sh
Following the download, Open the terminal, and navigate to the directory it was installed in, then type the following to install
sh springsource-tool-suite-2.5.2.RELEASE-e3.6.1-linux-gtk-installer.sh
A prompt will load, just use the default settings and remember to accept the license agreement (no option)
Netbeans
Prerequisite: Sun Java JDK installed
1. Download NetBeans 6.9 from NetBeans download page (select the version you want)
2. Once you have downloaded Open a terminal window and navigate to your Download directory (where you downloaded NetBeans installer script). Once you are at your download directory, type the following command to begin the installation.
sh netbeans-6.9rc2-ml-linux.sh
Source: http://linuxhub.net/2010/06/install-netbeans-on-ubuntu-10-04/
Tomcat
Check this great url
http://diegobenna.blogspot.com/2011/01/install-tomcat-7-in-ubuntu-1010.html
Now you should be all ready to try tomcat7.
First we must lift the server with the following command:
sudo /usr/share/tomcat7/bin/startup.sh
With this we get the following output on console:
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using JRE_HOME: /usr/local/jdk1.6.0_20/jre
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Verify that the JRE_HOME is where we define.
Now open your web browser and type the following url:
http://127.0.0.1:8080/
So we get the following page:
If we enter the administration Tomcat Manager we click on the menu or directly at URL (See – “Setting Tomcat password and permissions” section below):
http://127.0.0.1:8080/manager/html
Here we ask the user data from previous record in mind tomcat-users.xml.
I recommend testing the sample to make sure everything works ok, they are in the section “Miscellaneous” from the side menu or at the URL:
http://127.0.0.1:8080/examples/
Commands
Start server:
sudo /usr/share/tomcat7/bin/startup.sh
Stop server:
sudo /usr/share/tomcat7/bin/shutdown.sh
Automatic Starting
To make tomcat automatically start when we boot up the computer, you can add a script to make it auto-start and shutdown.
sudo gedit /etc/init.d/tomcat7
Now paste in the following:
# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
case $1 in
start)
sh /usr/share/tomcat7/bin/startup.sh
;;
stop)
sh /usr/share/tomcat7/bin/shutdown.sh
;;
restart)
sh /usr/share/tomcat7/bin/shutdown.sh
sh /usr/share/tomcat7/bin/startup.sh
;;
esac
exit 0
You’ll need to make the script executable by running the chmod command:
sudo chmod 755 /etc/init.d/tomcat7
The last step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should be on our way.
sudo ln -s /etc/init.d/tomcat7 /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat7 /etc/rc2.d/S99tomcat
Tomcat should now be fully installed and operational. Enjoy!
sudo /etc/init.d/tomcat7 restart
Setting Tomcat password and permissions
On the terminal (logged in as root), go to the Tomcat directory, in my case its
cd /usr/share/tomcat7/
Then move into the conf directory
cd conf/
Edit the tomcat-users.xml file
gedit tomcat-users.xml
Add the following line just before the closing tomcat-users xml tag ( tomcat-users )
<role rolename=”admin-gui”/>
<role rolename=”manager-gui”/>
<role rolename=”role1″/>
<user password=”tomcat” roles=”tomcat,role1″ username=”both”/>
<user password=”tomcat” roles=”role1″ username=”role1″/>
<user password=”tomcat” roles=”admin-gui,manager-gui,manager,admin” username=”tomcat”/>
Restart tomcat (ensure that the path to tomcat is correct in your case)
sh /usr/share/tomcat7/bin/shutdown.sh
sh /usr/share/tomcat7/bin/startup.sh
The default Tomcat username and password will now be tomcat
Add Apache Tomcat as a server in Netbeans
NB: Note that Apache tomcat does not appear on netbeans when you are creating a Java Web project.
You can fix this by going to Netbeans Tools->Servers
You can then select the tomcat version that is presently installed and save.