Search code examples
javasshvagrantvirtual-machinevagrant-provision

Vagrant java 1.6 to 1.8


I Installed vagrant on my machine with hashicorp-precise32 virtual machine. It installed java 1.6 whereas i want java 1.8. Do i have to install another virtual machine? How to get java 1.8?


Solution

  • Add below lines in your Vagrantfile, It will install Java 8 (accepting licenses) and also set the Environmental variables in your guest VM:

    sudo apt-get install -y software-properties-common python-software-properties
    echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
    sudo add-apt-repository ppa:webupd8team/java -y
    sudo apt-get update
    sudo apt-get install oracle-java8-installer
    echo "Setting environment variables for Java 8.."
    sudo apt-get install -y oracle-java8-set-default
    

    Moreover, you can refer Creating and Provisioning VM using Vagrant