downloading java 7 for the mac and a ubuntu linux vm

I’ve been thinking about setting up a Linux VM on my Mac for a little while now.  I already have a Chrome VM.   While I installed Java 7 on my Mac yesterday from Open JDK, I also wanted an “official” version.  In case I come across anything odd, I want a way to know if it is from the Mac version being not quite ready or “the way things work.”  Which gave me a reason/excuse to install the Linux VM.  This blog entry is about how to get started.

WARNING: Java 7 is not yet production ready.  See Java 7 Ships with Severe Bug.  (it has to do with loops not functioning properly and affects Lucene and likely other things.)

For the Mac

Download and install

  1. Download Java 7 dmg file
  2. Install it
  3. Optional go to Java in system preferences to choose Java 7 as default.  (I did not do this since it sounds experimental with known buts at this point.)
  4. Note the install location to reference is /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin.

Pointing to Java 7

Since Java 7 has reported stability problems, I didn’t want to set it in my PATH but only use it for selected command line invocations.  To facilitate, I set up the following in my .bash_profile:
alias javac7='/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin/javac'
alias java7='/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin/java'

To validate the aliases are working:

Jeanne-Boyarskys-MacBook-Pro:~ nyjeanne$ javac7 -version
javac 1.7.0-internal
Jeanne-Boyarskys-MacBook-Pro:~ nyjeanne$ java7 -version
openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-b00)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)

Linux VM on VirtualBox

Download and install

  1. Download ubutntu iso file.   It took a number of hours to download the iso file.  (I let it run overnight.)  While the download was less than 100MB, I downloaded Lion the night before (over 3GB) so my ISP may be throttling my connection speed now.  That or a slow server.  Note that you don’t need to create a USB stick or CD.  Just the iso file is fine.
  2. Create a new VirtualBox VM and set CD drive to read from the downloaded iso file.  Even those these instructions are for Windows, they were easy to follow on a Mac.
  3. Try to downloadthe .tar.gz file for Java 7.  I got a page not found so I tried the .rpm file.  This gave me errors when I installed and tried to run it.
     javac -version gave:
    Error occurred during initialization of VM.  java/lang/NoClassDefFoundError: java/lang/Object
  4. Deleted the bad install.
  5. Tried again to download the .tar.gz file for Java 7.  This time the path was found.

Pointing to Java 7

Since my Linux machine is a VM specifically for trying Windows 7, I felt safe adding it to the beginning of my PATH in the .profile file.

A really simple Java program

A really simple program using a Java 7 feature to further test your setup.

<pre>import java.util.*;

public class JeanneTest {
  public static void main(String... args) {
    System.out.println("test");
    Set<String> test = new HashSet<>();
  }
}

running chromium os on the mac on virtualbox

Now that the Chromebook is out and I’ve speculated about the target audience, I wanted to give running the Google OS a shot.  The closest I know that you can get is running Chronium OS which is the open source version.

The VM

This is the first time I needed a virtual machine on my mac.  I decided to start with VirtualBox since it is free for personal use.  It met my needs, so I’m done.  I should try Fusion at some point, but I didn’t need it for this.  I started by downloading the 82MB download for VirtualBox.

Setting up the VM

Since the “versioned” copy only provides a VM Ware and USB stick image, I tried following the instructions to convert the USB image to a vgi virtualbox file.  (The USB download is 324 MB.)  Launching the VM that way just gave me a black screen.

Next I tried getting the nightly snapshot build for VirtualBox from the “vanilla” site.  That worked well and I got the Chromium login screen.

I created the VM both times. using 512 MB RAM and Linux Ubuntu 32 bit.

Taking a screenshot

The only thing that that wasn’t obvious in VirtualBox was how to take a screenshot.   Thanks to this Techmix post, I learned you need to press left command to return the keyboard to the host mac and then use the right command key (with shift + 4) to grab a screenshot and have it sent to the desktop of the host mac.  And you have to do this every time because the keyboard focus returns to the VM every time you command+tab back to it.