Ubuntu: update-java-alternatives vs update-alternatives --config java
Ubuntu: update-java-alternatives vs update-alternatives --config java Question: 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? Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful): == This solution helped 104 people == sudo update-alternatives --config java Configures the default for the program "java". That's the Java VM. 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 VM 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: Are you talking about starting the IDE itself with different Java versions or using different versions in the IDE for compilation and running your app? For 1.: You can specify which JVM to use in the eclipse.ini, as described https://wiki.eclipse.org/Eclipse.ini#Specifying_the_JVM. I don't know how to do that for the Arduino IDE. For 2.: In Eclipse you can select the JRE/JDK to be used in Window - > Preferences -> Java -> Installed JREs. And under Java -> Compiler you could choose an older Java compliance if you wish. EDIT: https://www.digitalocean.com/community/tutorials/how-to-install-java- with-apt-on-ubuntu-18-04 also has a very nice explanation of everything related to Java on Ubuntu. With thanks & praise to God! With thanks to all the many who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music & music license: https://www.bensound.com/royalty-free-music | Images & images license: https://stocksnap.io/license and others | With thanks to user Stan Smith (https://askubuntu.com/users/172158), user fmmarques (https://askubuntu.com/users/442604), user Eric Carvalho (https://askubuntu.com/users/65926), user Benjamin Maurer (https://askubuntu.com/users/109432), and the Stack Exchange Network (http://askubuntu.com/questions/315646). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything should be amiss at Roel D.OT VandePaar A.T gmail.com.
Ubuntu: update-java-alternatives vs update-alternatives --config java Question: 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? Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful): == This solution helped 104 people == sudo update-alternatives --config java Configures the default for the program "java". That's the Java VM. 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 VM 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: Are you talking about starting the IDE itself with different Java versions or using different versions in the IDE for compilation and running your app? For 1.: You can specify which JVM to use in the eclipse.ini, as described https://wiki.eclipse.org/Eclipse.ini#Specifying_the_JVM. I don't know how to do that for the Arduino IDE. For 2.: In Eclipse you can select the JRE/JDK to be used in Window - > Preferences -> Java -> Installed JREs. And under Java -> Compiler you could choose an older Java compliance if you wish. EDIT: https://www.digitalocean.com/community/tutorials/how-to-install-java- with-apt-on-ubuntu-18-04 also has a very nice explanation of everything related to Java on Ubuntu. With thanks & praise to God! With thanks to all the many who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music & music license: https://www.bensound.com/royalty-free-music | Images & images license: https://stocksnap.io/license and others | With thanks to user Stan Smith (https://askubuntu.com/users/172158), user fmmarques (https://askubuntu.com/users/442604), user Eric Carvalho (https://askubuntu.com/users/65926), user Benjamin Maurer (https://askubuntu.com/users/109432), and the Stack Exchange Network (http://askubuntu.com/questions/315646). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything should be amiss at Roel D.OT VandePaar A.T gmail.com.