Monday, 13 April 2015

Setting up Java 8 Maven Ubuntu on Vagrant


  • VirtualBox is installed
  • Vagrant is installed
  • ssh and wget are available in PATH. Cygwin will do, e.g.: c:\cygwin\bin
  • We will use some of the Ubuntu setup scripts from ubuntu-equip - have a look.
You may want to download the Ubuntu Vagrant box so its available locally like so:
Create a project directory, I have E:\vagrant_java. In the project directory create a file named Vagrantfile with the following content:
Vagrant.configure(2) do |config| = "ubuntu.lts.64"
  config.vm.box_url = "file:///E:/VagrantBoxes/"
  config.vm.provision :shell, inline: 'wget --no-check-certificate && bash'
  config.vm.provision :shell, inline: 'wget --no-check-certificate && bash'
Bring up the vm, this may take a while as the relevant packages are provisioned from the net:
E:\vagrant_java>vagrant up
Lets have a look at what we ended up with
E:\vagrant_java>vagrant ssh
 vagrant@precise64:~$ java -version                                   
 java version "1.8.0_40"                                              
 Java(TM) SE Runtime Environment (build 1.8.0_40-b25)                 
 Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)                                                    

 vagrant@precise64:~$ readlink -f $(which java)

 vagrant@precise64:~$  /opt/maven/bin/mvn -version
 Apache Maven 3.2.5 (...)
 Maven home: /opt/maven
 Java version: 1.8.0_40, vendor: Oracle Corporation
 Java home: /usr/lib/jvm/java-8-oracle/jre
 Default locale: en_US, platform encoding: ISO-8859-1
 OS name: "linux", version: "3.2.0-23-generic", arch: "amd64", family: "unix"
All done :-)

No comments:

Post a Comment