Archive for January, 2014


How To Install Apache Tomcat 8 on Ubuntu without using apt-get

Sometimes you would want to install the latest version of tomcat server but your using apt-get doesn’t work for you. I had to go this route when my IntelliJIDEA IDE didn’t like my apt-get way installed tomcat server.

Before trying below make sure you have java installed and system variable JAVA_HOME has been set properly.

Step 1 : Get the latest version of tomcat server
wget http://mirror.atlanticmetro.net/apache/tomcat/tomcat-8/v8.0.0-RC10/bin/apache-tomcat-8.0.0-RC10.tar.gz

Note: Change the file url and file name based on what is latest available by looking into following URL:
http://mirror.atlanticmetro.net/apache/tomcat

Step 2 : Unzip tomcat installation files
tar xzvf apache-tomcat-8.0.0-RC10.tar.gz
sudo mv apache-tomcat-8.0.0-RC10 /usr/local
Step 3 : Setup system variable
nano ~/.bashrc

this will open up a text editor. Go to the end of the file (Alt+/) and add the following line:

export CATALINA_HOME=/usr/local/apache-tomcat-8.0.0-RC10

save and exit (Crlt+X and Y)

Step 4 : Load new configuration
. ~/.bashrc

Step 5 : Test your setup
Start tomcat server

sudo $CATALINA_HOME/bin/startup.sh

Then open this URL in your browser

http://localhost:8080

If everything is alright, you would see tomcat’s webapp GUI.


How to remove null reference in a Java List

If you have a list like below

List list = new ArrayList();

list.add("item1");
list.add("item2");
list.add(null);
list.add("item3");
list.add(null);
list.add("item4");
list.add("null");

Following one liner will remove all the null enteries from list

list.removeAll(Collections.singleton(null));