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) {
    Set<String> test = new HashSet<>();

what may or may not be in java 7 from the java road trip

Oracle talked about Java 7 at the first stop of the Java Road Trip. The main speaker was Brian Goetz, author of Java Concurrency In Practice.

Despite the disclaimer that everything including syntax is subject to change, the talk was pretty interesting.  Here are my notes.  (this was largely written on my iPad; please excuse any typos)


  • The JRE download is 13mb, but most code doesn’t get run by ordinary apps
  • The monolithic jdk makes new releases of platform take longer to roll out
  • Modularizing apps helps with jar hell and finding out at runtime that something is missing/wrong
  • Will provide mechanism for apps to express dependencies in way useful to both humans and tools
  • Based on concepts in Maven and OSGI
  • Current draft has: defining module and version number along with what module and versions or ranges you depend on
  • Classpath will be legacy mode, preferred mode will be to turn your app into a module

Multi lingual support

  • JVM is a managed code environment
  • Scala is a lot like java, but other dynamic languages (like Ruby) run slower because need to rely on reflection or code generation.
  • JVM is more like Smalltalk than like Java , but some places is tied to Java
  • Da Vinci machine project is targeted to adding features to better support dynamic languages. In particular dynamic method linkage which is being able to select version of method based on type of arguments
  • Invokedynamic vs invokevirtual for method selection and linking. Once calls stabilize, don’t look up in vm anymore, then inlines and is as fast as in  java.  This is a goal, need to get there.


  • Project coin – add half a dozen small language changes to simplify everyday tasks.  Would be at  level of enhanced for loop
  1. Reduce boilerplate of generics with the the diamond operator (not really an operator)
    Map<String, String> map  = new HashMap<>();
  2. Better numerical literals to make long numbers more readable.  Similarly for binary (long string of 0’s and 1’s)
    long cc= 123_5678_567;
  3. Collection literals – declare inline like we do with arrays and hard coded data.  More declarative. Like associative array in Perl, but may not go that far
  4. Automatically close resources in try/catch.  Better idiom
    try (InputStream in = createInputStream()){
    // code that reads in from stream goes here
    } // compiler will call close for you here


  • Goal: facilitate scalability across multiple cores
  • Fork join extend recursive action to split into subtasks and join to get answer.
  • Will be added to concurrency utilities.
  • Don’t have to tell it how many cores you have
  • ParallelIntArray class automates common operations filter, map and reduce so can say what want to do declaratively


  • Saving the best for last.
  • Like anonymous inner classes but without boilerplate of anonymous inner classes
  • Still debating syntax
  • Still debating whether return type should be declared
  • Still discussing how to extend interfaces (will be used to add closures for Collections).  Options are “static extension methods” like in C# where you statically “pretend there were these methods are on the class and call the static methods instead.”  Also discussing ” virtual extension methods.”  Either way the closures project will finally address the issue of api evolution
#(int x)(x*3).domorestuff()