How to run Tomcat 6 with Oracle Java 7 on Ubuntu 10.04

What to do, if you want to deploy web services written and compiled in Java 7 on a Tomcat application server installed on a Ubuntu 10.04 server? The official Ubuntu 10.04 repositories contain openjdk-6 and tomcat6.  So you can try to install Tomcat 7 (which runs with Java 7) or a version of Java 7, both from external sources or tarballs. I went the second way…

Install Java 7

You can, but you don’t need to uninstall openjdk-6. It’s your choice 😉

To install Java 7, I followed this tutorial (thanks to the author!). It uses a PPA to download and install the latest Oracle Java version:


Oracle JDK7 itself is not hosted in the PPA because that’s not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories); the package in the PPA automatically downloads Oracle Java JDK 7 from its official website and installs it on your computer, just like the flashplugin-installer package does.

Here’s a summary of all commands you need to successfully install and configure it as default java version. For explanations read original article:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo update-java-alternatives -s java-7-oracle
sudo apt-get install oracle-java7-set-default

Reset JAVA_HOME variable

After Java is successfully installed, you have to (re)set the JAVA_HOME variable to point to the newly installed version. That’s necessary to tell Tomcat which Java version to use for running its web services:

JAVA_HOME=/usr/lib/jvm/java-7-oracle/
export JAVA_HOME

Install Tomcat 6

If not already done, it’s time to install Tomcat 6 (it’s your choice which packages you really need ;-)):

apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-docs tomcat6-examples tomcat6-user

Verify installations

Now it’s time to start Tomcat 6 and to check the java version used:

service tomcat6 start

Scroll to the bottom of the application manager page and verify that Java 7 is used:

Tomcat 6 - server information

Finish

Your’re done! Feel free to tell me some hints to improve this article 🙂

Share

1 Kommentar von "How to run Tomcat 6 with Oracle Java 7 on Ubuntu 10.04"

  1. 28. September 2014 - 17:57 | Permalink

    Thanks for this comment.
    I’ve had this problem and now came to this page via google – and it helps. Thanks a lot.
    Kind regards
    Howard

Kommentar verfassen