Thursday, March 20, 2014

Creating a Java, Marklogic development stack on an Ubuntu 13.10 VirtualBox VM

I wrote about building a Java-based development stack using Ubuntu on a VirtualBox VM some time back (http://www.tractare.blogspot.com/2011/10/ubuntuvirtualboxjava-team-development.html, and http://www.tractare.blogspot.com/2011/10/ubuntuvirtualboxjava-team-development_04.html). But that was a couple of years ago and the technology has changed, so this is a rewrite. Also, that version didn't include Marklogic, which is a part of the stack for this particular application. So here's the stack I'm building out and the steps I took to get there.

First off, I'm building this in Virtual Box  4.3.8, installed on a Dell XPS laptop quad-code I7, 16GB RAM and dual 750GB HDD running Windows 7. Second, some of these kits I installed using PPAs, so if you have security concerns about PPAs, you'll need to find other ways for those tools.

The development stack I'm installing is this:

  • Ubuntu 64bit 13.10 with VB Guest Editions
  • DropBox
  • Oracle Java 7
  • JEdit
  • Git 
  • Maven
  • Tomcat 7
  • Chrome Browser
  • Eclipse Kepler
  • Marklogic 7
Installation Process:
A. Create the Virtual Machine...
  1. Downloaded the Ubuntu 13.10 64bit Desktop ISO  image from http://www.ubuntu.com/download/desktop
  2. Created a new VirtualBox VM targeting a linux/Ubuntu 64 bit OS with 10GB Ram and an 80GB Drive.
  3. Started that new VM and pointed it at the ISO image to install. (and chose to install rather than to try Ubuntu).
  4. After answering all the usual questions (where am I), restarted the VM and mounted the VB Guest Additions. The ran them via the autorun. Installing Guest Editions is a critical part of making a useful VM in VirtualBox. Don't leave home without it.
  5. Shut down the VM and opened the VirtualBox Manager Settings for my new VM; Changed the following:
  6. General->Advanced:
    Shared Clipboard=bidirectional
    Drag'n'Drop=Bidirectional
  7. System->Processor:
    4 CPUs
  8. Display->Video: 128MB
  9. OK to save all that, then start the VM again.
B. General VM Stuff, and Dropbox...
  1. The default gnome desktop has a bunch of stuff I don't use (word processing and so on),  so I removed and uninstalled them using the Ubuntu Software Center.
  2. I like to be able to do things in root, so I changed the root password. Saves having to sudo all the time!
    sudo passwd root
  3. Next, opened a terminal (and pinned it to the launcher) and started in on the stack. and I switched to root user (su root).
  4. Dropbox: I run Dropbox on the Windows machine and I don't see the point of running it in the guest Ubuntu VM as well. But I like having those folders and files available. So I create a shared folder and mount that in the Ubuntu VM.

    1. in Devices->Shared Folders Settings, create a new "Machine Folder" that points at the Dropbox folder on the Host.
    2. Create a directory of the same name in Ubuntu (Dropbox, in my case).
    3. Mount that:
       sudo mount -t vboxsf Dropbox /home/cup/Dropbox
C. Java, JEdit, Git, Maven...
  1. Java: If this is a new, clean Ubuntu install then there is no pre-installed Java. If you are trying to upgrade, you should check for and remove any extant Java installation.

    I installed Java via a PPA (http://askubuntu.com/questions/4983/what-are-ppas-and-how-do-i-use-them) by webupd8team (http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html). I ran these commands to add the PPA to the apt-get repo and update that repo, install Java7, and set up the various java 7 environment variables.
    
    add-apt-repository ppa:webupd8team/java
    apt-get update
    apt-get install oracle-java7-installerapt-get install oracle-java7-set-default
    
    
  2. JEdit: Installed this via the software center. This installed version 5.which is good enough for my purposes. 
  3. Git: simple - sudo apt-get install git
  4. Maven -- also simple sudo apt-get install maven
  5. Tomcat7 -- Installed directly from the Ubuntu Software Center.
D. Chrome Browser...
  1. Chrome Browser: Via PPA:

    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
    sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
    apt-get update
    apt-get install google-chrome-stable
E. Eclipse...
  1. Eclipse: A bit of a pain in the neck, I followed this guide: http://blog.thismagpie.com/2012/07/installing-eclipse-juno-42-on-lubuntu.html. Downloaded the Eclipse Linux 64 tar.gz distribution and saved that file. Then ran these commands as root:
    
    tar -zxvf eclipse-...
    sudo cp -r eclipse /opt
    cd /usr/local/bin
    cp -r /opt/eclipse/eclipse eclipse
    
    After that, I ran eclipse from the command line and then pinned it to the launcher.
  2. One issue I had with Eclipse was that the command menus didn't work. I had to edit the eclipse.desktop file in ~/.local/share/applications to get it to work by commenting out the Exec and adding this one:
    
    
    Exec=env UBUNTU_MENUPROXY= /usr/local/bin/eclipse
F. Marklogic...
  1. Downloaded Marklogic7 for 64Bit RedHat Linix and ran these commands
    apt-get install alien
    alien --to-deb --verbose MarkLogic-4.1-6.x86_64.rpm
    dpkg -i marklogic_4.1-6_amd64.deb
    /etc/init.d/MarkLogic start
    
    The one issue I had with the ML install is that the Marklogic script in /etc/init.d runs under /bin/sh and Ubuntu's default shell is bash. So I changed the first line of that script to #!/bin/bash
And that's it. I now have a reasonable development stack to create Web based Java code using Marklogic.