Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In order to install a development environment for an older version of Android, I need to have Java 6 installed. I already, however, have Oracle Java 7 installed on my system and would like to keep it that way.

How can I install Java 6 so that the java and javac commands will refer to it in a given directory (and its sub-directories,) without messing anything up with respect to Java 7 on the rest of my system?

share|improve this question
up vote 1 down vote accepted

This sounds like this similar answer by me could help:

Install both Java versions and choose the default one for the system: update-java-alternatives vs update-alternatives --config java

Not sure what the android SDK includes etc., I haven't used it. But if you work with Eclipse, you can choose a Java Version in the Settings.

The alternative, as written in the answer above, is to create a script that will edit PATH or use update-java-alternatives to change the VM and start your application.

share|improve this answer

No need to install older version of JDK. If you want to use older version of JDK then you can do it with latest version also.

Compile your program with these options. -source & -target.

For example,

javac -source 1.6 -target 1.6

If you are using eclipse then it always asks you for jdk version before making classes or projects.

share|improve this answer
If you think my answer helped you! then mark it correct! :) – Deepen Apr 29 '14 at 15:59

Your Answer


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.