Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running jetty 7.6 on ubuntu. It's serving live traffic. That particular version of jetty needs java 6.

Now I want to install java 7 on that machine. Will that mess up my jetty instance that's currently live?

Also, will updating to java 7 make ubuntu choose it as the default jdk to use the next time I invoke a java app? If possible I'd like to:

  1. Install java 7 jdk.
  2. Not make it the default, but allow me to explicitly invoke an app using java 7.

This will let me test newer versions of jetty (that require java 7) without messing up my live installation.

Thanks

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Depending on how you have Java 6 installed, the answer might be slightly different.

When installing Java through .deb or apt-get, the installation scripts will typically leverage the Debian alternatives system. The Debian alternatives system is just a simple solution to having multiple runtimes/versions of multiple applications on the same system by creating symbolic links in different locations.

Please note that if you installed Java from binary or source, that this might not apply (unless you configured it yourself).

To check to see if java is leveraging alternatives, run update-alternatives --list java. This will either return:

update-alternatives: error: no alternatives for java.

or

java - auto mode
  link currently points to /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java
/usr/lib/jvm/java-6-openjdk-i386/jre/bin/java - priority 1061
  slave java.1.gz: /usr/lib/jvm/java-6-openjdk-i386/jre/man/man1/java.1.gz
/usr/lib/jvm/java-7-openjdk-i386/jre/bin/java - priority 1051
  slave java.1.gz: /usr/lib/jvm/java-7-openjdk-i386/jre/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-6-openjdk-i386/jre/bin/java'.

If your java installation is leveraging the alternatives system, you can easily install multiple versions without disturbing the existing runtime. In the above example, I have two versions of Java installed, openjdk6 and openjdk7. If I just run /usr/bin/java -version, I am going to get the "best" alternative, which is currently pointing to openjdk6. I can also switch what "best" alternative to use, so that all applications that use the default java will point to one or the other.

In summary, if your application is explicitly calling the java binary (and not the alternative) then you're fine. If your application is using /usr/bin/java, then you want to make sure that installing another java version doesn't conflict with the system alternatives.

To find out more about alternatives and all the fun things you can do with them, take a look at the manual with man update-alternatives.

tl;dr No, they shouldn't conflict. Make sure that anything that depends on Java 6 or Java 7 is using the actual binary (not a symbolic link), as just running /usr/bin/java can have different results based on what your system alternatives look like.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.