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

On Ubuntu 12.04 LTS I have installed Sun's JDK7, Eclipse, and the Arduino IDE. I want the Arduino to use OpenJDK 6 and want Eclipse to use Sun's JDK 7.

From my understanding I need to manually choose which Java to use before running each application. This led me to the update-java-alternatives -l command. When I run this I only see the following:

java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64

but when I run 'update-alternatives --config java' I see the following:

*0  /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   auto mode
1  /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   manual mode
2  /usr/lib/jvm/jdk1.7.0/bin/java                   manual mode
3  /usr/lib/jvm/jre1.7.0/bin/java                   manual mode

I don't understand why the update-java-alternatives doesn't display the same 3 options. I also don't understand how to switch between OpenJDK6 and JDK7. How I can go about using the OpenJDK6 for Arduino development and Sun JDK7 for Eclipse/Android development?

share|improve this question

1 Answer 1

up vote 22 down vote accepted

sudo update-alternatives --config java

Configures the default for the program "java". That's the Java interpreter.

sudo update-alternatives --config javac

Configures the default Java compiler.

You can also see that, because the first command lists a lot of "JRE" (Java Runtime Environment) folders and the Program is just called "java".

If I check which version is being used by issuing the command java -version or javac -version

I can see, that each command changes the program being used. However, using update-java-alternatives with a JDK Version changes BOTH programs for me. Using the first commands, you can use a Java Interpreter and Java Compiler from different JDKs.

So it seems you need to install the openjdk-7-jdk package as well. It looks like you only installed openjdk-7-jre.

As for switching for different development environments. Well, either you switch manually each time, or maybe you can make the IDE select the javac version directly. Not sure about that, sorry. Maybe you can also work with environmental variables. But you should check with your development environments documentation.

share|improve this answer

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.