Skip to main content

Building Java 9 on Windows with Visual Studio 2013 Community

As the JDK moves to Visual Studio 2013 for its toolchain, this version focuses on building Java 9 on Windows (10 64bits) with Visual Studio 2013 (Community). As it takes a few short-cuts, refer to the Java 9 with plain Windows SDK version or/and to the Java 8 version (for using plain Cygwin).

  1. Create a C:\dev\ directory

  2. Download and install Visual Studio 2013 Community

    1. Download (it may be faster to download the ISO)

    2. Install

Using JDK9/Jigsaw-m2 for Netbeans projects

Last updated: 2015-12-06, nightly builds (aka Development builds) now support the current JDK 9, so this post is no longer of any use.

When Jigsaw/m2 appeared on the OpenJDK, I tried it with my usual guinea pig, NetBeans. Launching was fine, however using Jigsaw as the platform for a project was not due to the new image (JEP 220). In due time it will be supported but currently it isn’t. So I set out to see if I could not add some support myself.

Building OpenJFX on Windows

This post is a step by step to build OpenJFX on Windows (8.1 64bits). It is inspired from the official instructions though it drops Visual Studio Express (which does not come with 64bits compiler and linker) in favour of plain SDK. It also uses Babun rather than plain Cygwin.

  1. Create a C:\dev directory

  2. Download and install a Java 8 JDK (I’m using 8u20 here)

  3. Download Gradle 1.8 and extract it into C:\dev

  4. Download and install Windows SDK 7.1 (no need for the samples or .Net tools)

Building Java 9 on Windows

This version focuses on building Java 9 on Windows (8.1 64bits) and takes a few short-cuts from the Java 8 version (refer to that version if you get issues).

Last updated: 2015-05-14, fixed JDK image path, Freetype 2.5.5, use cygpaths

  1. Download and install Windows SDK 7.1 (there is no need for the samples and .Net tools)

  2. Download and install Microsoft DirectX 9.0 SDK (the ReadMe says the version from summer 2004, however this does not seem to still be available from Microsoft, the version from June 2010 seems to be a working replacement)

Hacking NetBeans: Improving the Manage Groups dialog

In my previous post I tried to show how I’d like to improve NetBeans Manage Groups dialog, in this one I’ll try to show how to.

Setting up:

  1. Get and install Mercurial

  2. Clone http://hg.netbeans.org/main

  3. Get Ant (1.9.3 worked for me)

  4. Make sure you have Java 7 (8 doesn’t work)

  5. Open a shell in your working copy directory to do a first build that’s needed for creating Ant tasks that are used by the NetBeans projects

Projects groups in NetBeans

One of the features of NetBeans that I use the most is the Projects Groups. It allows to arbitrarily group projects together then switch from one group to another. For instance as below, projects related to a lambda lab, project related to the Yoko Tsuno site I help maintaining in a Yoko group, and the default (none) group. Or to switch between a feature development group and a bug fix group.

WorldClock and Lambdas

The second Java 8 feature to use in WorldClock are the Lambdas.

The simplest way to start using them seems to apply Netbeans refactoring hints.

These hints are of two kinds for WorldClock:

  • Iterations:

PreJava8:

for (City city : cities) {
   city.paint(g, width, height, isFullScreen);
}

Java8:

cities.stream().forEach((city) -> {
    city.paint(g, width, height, isFullScreen);
});

It may not bring much in this instance though.

  • Single method anonymous inner classes:

PreJava8:

mnuiShow.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e)       {
        showWindow();
      }
});

WorldClock and JSR310

With JSR310 (Date and Time API) in Java 8 and the small 0.7 release of WorldClock done, I can update WorldClock to the new API.

First the time used for day and night drawing:

(in WorldClockBoard)

PreJava8:

Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(“GMT”));
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR);
int hours = cal.get(Calendar.HOUR_OF_DAY);
int minutes = cal.get(Calendar.MINUTE);
int seconds = cal.get(Calendar.SECOND);

Java8:

OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
int day = now.getDayOfMonth();
int month = now.getMonthValue(); int year = now.getYear();
int hours = now.getHour();
int minutes = now.getMinute();
int seconds = now.getSecond();