View Full Version : Change Java Version on the Fly

September 4th, 2012, 12:53 PM
Hello All,
I am trying to setup an android development environment. Unfortunately it needs java6. I have java7 installed and i added java6 as well. I am trying to make a small bash script that changes my path to use java6 only when i am going to compile android.

Here is what i added to .bashrc

#added as function to automatically set java for android development
function android_env {
export PATH
cd ~/Programming/android_os

however it does not seem to work but i am not sure why... Any tups would be appreciated, thanks!

September 4th, 2012, 03:21 PM
I'm not sure about the script. However, rather than making a script, you should be able to change the default java on the fly using 'alternatives'. See the "Choosing the default java to use" section of the Community Documentation:


This will allow you to just run:

sudo update-alternatives --config java

and choose which you want from a menu.