Sunday, 14 May 2017

Building OpenJDK 9 with OpenJFX 9 on Ubuntu (VBox and WSL)

Wanting to test Windows Subsystem for Linux, I've refreshed my steps for building on Ubuntu.
(Dependencies come from the helpful configure messages for the JDK and from the OpenJFX wiki)

Quick steps for installing WSL:
  1. Activate the developer's mode in settings
  2. In an administrator PowerShell console run:
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  3. Open Bash and install Ubuntu
 (the following also applies to a VirtualBox VM)

 To build OpenJFX and OpenJDK 9:
  1. Install the dependencies:
    sudo apt install mercurial openjdk-8-jdk make unzip zip g++ libx11-dev libxext-dev libxrender-dev libxtst-dev libcups2-dev libfreetype6-dev libasound2-dev ksh bison flex gperf libasound2-dev libgl1-mesa-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libjpeg-dev libpng-dev libxml2-dev libxslt1-dev libxt-dev libxxf86vm-dev pkg-config x11proto-core-dev x11proto-xf86vidmode-dev libavcodec-dev libgtk2.0-dev libgtk-3-dev libxtst-dev libudev-dev libavformat-dev
  2. Create the dev directory:
    mkdir ~/dev
    cd ~/dev
  3. Retrieve specific dependencies for OpenJFX:
    wget https://services.gradle.org/distributions/gradle-3.1-bin.zip
    unzip gradle-3.1-bin.zip
    export PATH=$PATH:~/dev/gradle-3.1/bin

    wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.2-bin.zip
    unzip apache-ant-1.8.2-bin.zip
    export PATH=$PATH:~/dev/apache-ant-1.8.2/bin

    wget http://download.java.net/java/jdk9/archive/168/binaries/jdk-9-ea+168_linux-x64_bin.tar.gz
    gunzip jdk-9-ea+168_linux-x64_bin.tar.gz
    tar x -f jdk-9-ea+168_linux-x64_bin.tar
  4. Get the sources:
    hg clone http://hg.openjdk.java.net/openjfx/9-dev/rt jfx

    hg clone http://hg.openjdk.java.net/jdk9/jdk9/
    cd ~/dev/jdk9
    bash ./get_source.sh
  5. Set the env variables for OpenJFX:
    export _JAVA_OPTIONS="-Dsun.reflect.debugModuleAccessChecks=true --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED -Dorg.gradle.daemon=false"

    export JAVA_HOME=~/dev/jdk-9/
    export JDK_HOME=~/dev/jdk-9/
  6. Build OpenJFX:
    cd ~/dev/jfx
    gradle
  7. Unset the env variables for OpenJFX (to avoid interfering with the configuration of OpenJDK):
    export -n _JAVA_OPTIONS
    export -n JAVA_HOME
  8. Configure and Build OpenJDK:
    cd ~/dev/jdk9
    bash configure --with-import-modules=`echo ~/dev/jfx/build/modular-sdk/`
    make images
  9. Enjoy

Sunday, 2 April 2017

WorldClock and Jigsaw (the Java 9 edition)

Although I have other applications running as Jigsaw modules, I hadn't migrated WorldClock to it. Now it is.


WorldClock is currently composed of a set of 'modules':
  • config
    that will read/write a configuration from/to disk
  • geonames4lhwc
    that will connect to the Geonames service and retrieve a list of cities for a search string
  • application
    the application
  • editor
    an editor for the configuration
  • panel
    the WorldClock panel that shows the day and night on Earth
  • schema
    the XML schema for the configuration file
where
  • config depends on schema
  • editor depends on schema, config, geonames4lhwc and org.jdesktop:appframework
  • application depends on panel
  • schema and geonames4lhwc depend on XML schemas

With a new version of Java, I usually
  1. get my program to run with the new version
  2. get my program to compile with the new version

With Jigsaw the following steps can be added
  1. create modules
  2. run in 'modular mode'
  3. create a custom image

Let see how it goes.

1. Run WorldClock with JDK 9


The first step to move WorldClock to Jigsaw is to try to run the code compiled with Java 8 on JDK 9:
  • This works without issue for application.
  • But fails for editor with:
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
        at lh.worldclock.editor.EditorView.initComponents(EditorView.java:113)
    This because it belongs to a Java EE API and in JDK 9 Java EE APIs are not resolved by default for code on the class path (this to make it easier for the applications servers... see http://openjdk.java.net/jeps/261#EE-modules)
    To fix it '--add-modules java.xml.bind' needs to be added to the command line.

2. Compile WorldClock with JDK 9


The second step is to compile with JDK 9:

Building requires using Maven compiler 3.6.1 plugin in the main pom:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.6.1</version>
</plugin>
 As well setting the release to 9, via the property:
<maven.compiler.release>9</maven.compiler.release>
 (for NetBeans, <maven.compiler.source>9</maven.compiler.source> and <maven.compiler.target>9</maven.compiler.target> are also added)

Then for the subprojects some ajustments are required to add the Java EE API modules:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <compilerArgs>
      <arg>--add-modules</arg>
      <arg>java.xml.bind</arg>
    </compilerArgs>       
  </configuration>
</plugin>
for config, editor, geonames4lhwc

and
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <compilerArgs>
      <arg>--add-modules</arg>
      <arg>java.xml.ws.annotation,java.xml.bind</arg>
    </compilerArgs>       
  </configuration>
</plugin>
for schema.

geonames4lhwc and schema create some classes from XSDs, this used to be done with maven-jaxb-plugin, however this plugin currently does not work with JDK 9, the jaxb2-maven-plugin does not work either, but in its 43rd issue https://github.com/mojohaus/jaxb2-maven-plugin/issues/43 Gunnar Morling has a workaround consisting in calling maven-antrun-plugin and exec-maven-plugin to create the classes in a less integrated manner.

This is the workarround for geonames4lhwc:
<!-- Create target dir -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.4</version>
  <executions>
    <execution>
      <phase>generate-sources</phase>
      <configuration>
        <tasks>
          <echo message="Creating target/generated-sources/jaxb"/>
          <mkdir dir="./target/generated-sources/jaxb"/>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>

<!-- Invoke xjc -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>generate schema types</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>exec</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <executable>xjc</executable>
    <arguments>
      <argument>-enableIntrospection</argument>
      <argument>-encoding</argument>
      <argument>UTF-8</argument>
      <argument>-p</argument>
      <argument>lh.worldclock.geonames.schema</argument>
      <argument>-extension</argument>
      <argument>-target</argument>
      <argument>2.1</argument>
      <argument>-d</argument>
      <argument>target/generated-sources/jaxb</argument>
      <argument>src/main/schema/geonames.xsd</argument>
    </arguments>
  </configuration>
</plugin>

<!-- Add target dir to compilation -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>target/generated-sources/jaxb</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>
And this is the workarround for schema:
<!-- Create target dir -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.4</version>
  <executions>
    <execution>
      <phase>generate-sources</phase>
      <configuration>
        <tasks>
          <echo message="Creating target/generated-sources/jaxb"/>
          <mkdir dir="./target/generated-sources/jaxb"/>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>

<!-- Invoke xjc -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>generate schema types</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>exec</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <executable>xjc</executable>
    <arguments>
      <argument>-enableIntrospection</argument>
      <argument>-encoding</argument>
      <argument>UTF-8</argument>
      <argument>-p</argument>
      <argument>lh.worldclock.config.schema</argument>
      <argument>-extension</argument>
      <argument>-target</argument>
      <argument>2.1</argument>
      <argument>-d</argument>
      <argument>target/generated-sources/jaxb</argument>
      <argument>src/main/resources/worldclock.xsd</argument>
    </arguments>
  </configuration>
</plugin>

<!-- Add target dir to compilation -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>target/generated-sources/jaxb</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>

With those the projects now compile.

3.  Create modules


The third step is to create 'Jigswaw' modules for the 'Maven' modules:
This by adding a module-info.java in src/main/java for each module.

The simplest module-info is for panel:
module lh.worldclock.panel
{
  exports lh.worldclock.core;
  requires java.desktop;
}
It exports the package lh.worldclock.core and requires the module java.desktop (which contains Swing).


Next is application:
module lh.worldclock.application
{
  requires lh.worldclock.panel;
  requires java.xml;
  requires java.desktop;
}
It requires the modules lh.worldclock.panel (to access the classes in the exported lh.worldclock.core package),  java.xml (for loading the XML configuration) and java.desktop (for Swing and AWT).



Next is schema:
module lh.worldclock.schema
{
  exports lh.worldclock.config.schema;
  opens lh.worldclock.config.schema to java.xml.bind;
  requires java.xml.ws.annotation;
  requires java.xml.bind;
}
It exports the generated package lh.worldclock.config.schema and
requires java.xml.bind and java.xml.ws.annotation,
it also opens lh.worldclock.config.schema to java.xml.bind that is it allows java.xml.bind (aka JAXB)
to use reflection on lh.worldclock.config.schema in order to instanciate its classes.


Next is config:
module lh.worldclock.config
{
  exports lh.worldclock.config;
  requires lh.worldclock.schema;
  requires java.xml.bind;
}
It exports lh.worldclock.config and requires java.xml.bind (JAXB) and lh.worldclock.schema (for lh.worldclock.config.schema).


Next is geonames4lhwc:
module lh.worldclock.geonames4lhwc
{
  exports lh.worldclock.geonames4lhwc;
  exports lh.worldclock.geonames.schema;
  opens lh.worldclock.geonames.schema;
  requires java.xml.bind;
  requires java.logging;
}
It exports the package lh.worldclock.geonames4lhwc, the generated package lh.worldclock.geonames.schema,
opens that same package,
requires java.xml.bind and java.logging (the later so that the exceptions in
lh.worldclock.geonames4lhwc.GeonamesWSWrapper can be logged)


Finally is the editor:
open module lh.worldclock.editor
{
  exports lh.worldclock.editor to appframework;
  requires lh.worldclock.schema;
  requires lh.worldclock.config;
  requires lh.worldclock.geonames4lhwc;
  requires appframework;
  requires swing.worker;
  requires java.desktop;
  requires java.logging;
  requires java.xml.bind;
}
It requires java.xml.bind (JAXB), java.logging, java.desktop (Swing), the schema, config and geonames4lhwc worldclock modules,
the swing.worker and appframework are modules providing the application framework on which
the editor is based.
The package lh.worldclock.editor is only exported to the appframework module so that it can't
be used by another module.
And the module is open so that its resources (icons and properties) can be accessed
(opening the resources packages does not work since they are not known in the compile phase of Maven and opened packages are validated by the compiler).

4. Run in 'modular mode'


The fourth step is to run the application and editor in 'modular mode'.

For that first lets create the module path, the class path for modules, by copying all the jars created by the project as well as appframework and swing-worker to a single directory. Although appframework and swing-worker don't have module-info by being put on the module path they be treated as (automatic) modules.
(on Windows:
rmdir /S /Q target\mods
mkdir target\mods
copy %USERPROFILE%\.m2\repository\org\jdesktop\appframework\1.0.3\appframework-1.0.3.jar target\mods
copy %USERPROFILE%\.m2\repository\org\jdesktop\swing-worker\1.1\swing-worker-1.1.jar target\mods
copy application\target\application-0.8-SNAPSHOT.jar target\mods
copy config\target\config-1.1-SNAPSHOT.jar target\mods
copy editor\target\editor-1.1-SNAPSHOT.jar target\mods
copy geonames4lhwc\target\geonames4lhwc-1.1-SNAPSHOT.jar target\mods
copy panel\target\panel-0.8-SNAPSHOT.jar target\mods
copy schema\target\schema-1.1-SNAPSHOT.jar target\mods
)

Then to run application:
java --module-path target\mods --module lh.worldclock.application/lh.worldclock.WorldClock

Likewise for editor:
java --module-path target\mods --module lh.worldclock.editor/lh.worldclock.editor.EditorApp

5. Create a custom image


The last step is to make use of a new feature in JDK 9 that allow to create a custom JDK/JRE image with just the modules needed by the application. It is provided by running the command jlink.

For application it is simple:
jlink --output app --module-path target\mods;"%JDK%\jmods" --add-modules lh.worldclock.application --launcher worldclock=lh.worldclock.application/lh.worldclock.WorldClock
where
  • app is the directory that will contain the custom image
  • %JDK% is the path to the JDK, its jmods directory contains the JDK modules (packaged as .jmod to also include extra data, like binaries or configurations)
  • --add-modules will list the root modules, with other modules added from the module paht when they are dependencies of the root modules
  • --launcher creates a launcher script/.bat that will launch java in the custom image with the given module/main class
    (on Windows, the java command can be replaced with javaw to avoid the console window by editing the .bat)
For the editor it is more involved... as it depends on appframework and swing-worker which automatic module (thus don't have explicit dependencies as they don't have a module-info and they may have some access to the class path which could not quite be included in the image) and so can't be added to an image.

So appframework and swing-worker need to be turned into proper modules.
This means adding a module-info for each then updating their jars to include it.

Module-info for appframework (in modextra\appframework\module-info.java):
open module appframework
{
  exports org.jdesktop.application;
  requires swing.worker;
  requires java.desktop;
  requires java.logging;
}
Module-info for swing-worker (in modextra\swingworker\module-info.java):
module swing.worker
{
  exports org.jdesktop.swingworker;
  requires java.desktop;
}
Since appframework has a dependency on swing-worker, lets first modularise swing-worker.
First extract its content in a directory:
cd target
mkdir swing-worker-1.1
cd swing-worker-1.1
jar --extract --file ..\..\target\mods\swing-worker-1.1.jar
cd ..
Then compile the module-info (the compilation requires the exploded jar):
javac -d swing-worker-1.1 ..\modextra\swingworker\module-info.java
Then update the jar with the compiled module-info:
jar --update --file mods\swing-worker-1.1.jar -C swing-worker-1.1 module-info.class

Similarly for appframework:

Extract its content in a directory:
mkdir appframework-1.0.3
cd appframework-1.0.3
jar --extract --file ..\..\target\mods\appframework-1.0.3.jar
cd ..
Compile (note the -p mods to include the swing-worker module):
javac -p mods -d appframework-1.0.3 ..\modextra\appframework\module-info.java
Jar update:
jar --update --file mods\appframework-1.0.3.jar -C appframework-1.0.3 module-info.class

Now the editor's image can be created with:
jlink --output editor --module-path mods;"%JDK%\jmods" --add-modules lh.worldclock.editor --launcher editor=lh.worldclock.editor/lh.worldclock.editor.EditorApp

And that's it.
WorldClock is modularised and even have 'stand alone' application and editor.

The full source code as well as the batch files can be found on GitHub on the Jigsaw branch of WorldClock.

Sunday, 10 April 2016

Building OpenJDK 9 with OpenJFX 9 on Windows, the Jigsaw way

This post is a step by step to build the OpenJDK 9 with OpenJFX 9 with the Jigsaw changes on Windows (10 64bits).
It is based on the Jake instructions.

Update: 2017-01-21: OpenJFX has updated build requirements

  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
      • uncheck all the options
      • or download AdminDeployment.xml to C:\dev\temp then start the installation with:
        vs_community.exe /AdminFile C:\dev\temp\AdminDeployment.xml
    3. Add the path to MSBuild to the PATH environement variable (required to build Freetype):
      C:\Program Files (x86)\MSBuild\12.0\Bin
  3. Download and install the Mercurial for Windows 
  4. Download and install Java 8 (for OpenJDK)
  5. Download and install JDK 9 b150+ (for OpenJFX)
  6. Download and install Babun, then use its package manager to install zip :
    pact install zip
  7. Download Freetype source (2.6.2) and extract to C:\dev\freetype-2.6.2
  8. Download Gradle 3.1 (for OpenJFX) and extract it into C:\dev
  9. Download Ant 1.8.2 (for OpenJFX) and extract it into C:\dev

     
  10. Get the JDK's source
    In the Babun console:
    cd /cygdrive/c/dev
    hg clone http://hg.openjdk.java.net/jdk9/jdk9/
    cd /cygdrive/c/dev/jdk9
    ./get_source.sh
  11. Get OpenJFX' source
    In the Babun console:
    cd /cygdrive/c/dev
    hg clone http://hg.openjdk.java.net/openjfx/9/rt/ jfx9


  12. Build OpenJFX
    In the 'DOS' console:
    cd C:\dev\jfx9
    set GRADLE_HOME=C:\dev\gradle-3.1
    set ANT_HOME=C:\dev\apache-ant-1.8.2
    set JAVA_HOME=C:\Program Files\Java\jdk-9
    set PATH=%PATH%;%JAVA_HOME%\bin;%GRADLE_HOME%\bin;%ANT_HOME%/bin;%USERPROFILE%\.babun\cygwin\bin
    set _JAVA_OPTIONS=-Dsun.reflect.debugModuleAccessChecks=true --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED


    gradle
  13. Run the auto-conf script for OpenJDK
    In the Babun console:
    cd /cygdrive/c/dev/jdk9
    bash configure --with-freetype-src=/cygdrive/c/dev/freetype-2.6.2 --with-import-modules=/cygdrive/c/dev/jfx9/build/modular-sdk
  14. Time for cooking
    make images
    
    
    
  15. Once done, open a new 'DOS' console and navigate to
    cd C:\dev\jdk9\build\windows-x86_64-normal-server-release\images\jdk
    check that java runs:
    bin\java -version
    or for something a bit more visual:
    bin\jconsole
  16.  To check JavaFX,
    in the 'DOS' console compile the sample apps:
    cd C:\dev\jfx9
    set GRADLE_HOME=C:\dev\gradle-3.1
    set ANT_HOME=C:\dev\apache-ant-1.8.2
    set JAVA_HOME=C:\Program Files\Java\jdk-9
    set PATH=%PATH%;%JAVA_HOME%\bin;%GRADLE_HOME%\bin;%ANT_HOME%/bin;%USERPROFILE%\.babun\cygwin\bin
    set _JAVA_OPTIONS=-Dsun.reflect.debugModuleAccessChecks=true --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED


    set JIGSAW_HOME=C:\dev\jdk9\build\windows-x86_64-normal-server-release\images\jdk
    gradle apps

    then launch:
    %JIGSAW_HOME%\bin\java -jar C:\dev\jfx9\apps\samples\Ensemble8\dist\Ensemble8.jar
  17. hack!

Tuesday, 5 January 2016

Building OpenJDK with OpenJFX Jigsaw prototype on Windows

This post is a step by step to build the OpenJDK with OpenJFX Jigsaw prototype on Windows (10 64bits).
For OpenJDK 9 and OpenJFX 9 see the adjusted page.

Update 2016-10-08: Mercurial URL changed

  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
      • uncheck all the options
      • or download AdminDeployment.xml to C:\dev\temp then start the installation with:
        vs_community.exe /AdminFile C:\dev\temp\AdminDeployment.xml
    3. Add the path to MSBuild to the PATH environement variable (required to build Freetype):
      C:\Program Files (x86)\MSBuild\12.0\Bin
  3. Download and install the Mercurial for Windows 
  4. Download and install Java 8 (for OpenJDK)
  5. Download and install JDK 9 b109
  6. Move C:\Program Files\Java\jdk-9\lib\jfxrt.jar out of the way (rename it jfxrt.jar.disabled for instance)
  7. Download and install Babun, then use its package manager to install zip :
    pact install zip
  8. Download Freetype source (2.6.2) and extract to C:\dev\freetype-2.6.2
  9. Download Gradle 2.11 and extract it into C:\dev

     
  10. Get Jake's source
    In the Babun console:

    cd /cygdrive/c/dev
    hg clone http://hg.openjdk.java.net/jigsaw/jake
    cd /cygdrive/c/dev/jake
    ./get_source.sh
  11. Get OpenJFX Jigsaw prototype source
    In the Babun console:
    cd /cygdrive/c/dev
    hg clone http://hg.openjdk.java.net/openjfx/sandbox-9-jake/rt/ jfx-jake


    
    
  12. Build OpenJFX
    In the 'DOS' console:
    cd C:\dev\jfx-jake
    set GRADLE_HOME=C:\dev\gradle-2.11
    set JAVA_HOME=C:\Program Files\Java\jdk-9
    set PATH=%PATH%;%JAVA_HOME%\bin;%GRADLE_HOME%\bin;%USERPROFILE%\.babun\cygwin\bin

    gradle
  13. Run the auto-conf script for OpenJDK
    In the Babun console:
    cd /cygdrive/c/dev/jake
    bash configure --with-freetype-src=/cygdrive/c/dev/freetype-2.6.2 --with-import-modules=/cygdrive/c/dev/jfx-jake/build/modular-sdk
  14. Time for cooking
    make images
    
    
    
  15. Once done, open a new 'DOS' console and navigate to
    cd C:\dev\jake\build\windows-x86_64-normal-server-release\images\jdk
    check that java runs:
    bin\java -version
    or for something a bit more visual:
    bin\jconsole
  16.  To check JavaFX,
    in the 'DOS' console compile the sample apps:
    cd C:\dev\jfx-jake
    set GRADLE_HOME=C:\dev\gradle-2.11
    set JAVA_HOME=C:\Program Files\Java\jdk-9
    set PATH=%PATH%;%JAVA_HOME%\bin;%GRADLE_HOME%\bin;%USERPROFILE%\.babun\cygwin\bin

    set JIGSAW_HOME=C:\dev\jake\build\windows-x86_64-normal-server-release\images\jdk
    gradle apps

    then launch:
    %JIGSAW_HOME%\bin\java -jar C:\dev\jfx-jake\apps\samples\Ensemble8\dist\Ensemble8.jar
  17. hack!

Friday, 22 May 2015

Building OpenJFX 9 on Windows with Visual Studio 2013 Community

This post is a step by step to build OpenJFX 9 on Windows (10 64bits). It is a refresh of the "Building OpenJFX on Windows" for the 9 sources and with Visual Studio 2013 (Community here) which is now used by Oracle.

Last updated: 2016-10-08, Mercurial URL change
  1. Create a C:\dev directory
  2. Download and install JDK 9 b109
  3. Delete C:\Program Files\Java\jdk-9\lib\jfxrt.jar as otherwise the build won't succeed 
  4. Download Gradle 2.11 and extract it into C:\dev
  5. Download and install Visual Studio 2013 Community
    1. Download (it may be faster to download the ISO)
    2. Install
      • uncheck all the options
      • or download AdminDeployment.xml to C:\dev\temp then start the installation with:
        vs_community.exe /AdminFile C:\dev\temp\AdminDeployment.xml
  6. Download and install Babun
  7. Download and install Mercurial
  8. In C:\dev open a standard console
  9. Get the sources:
    In the console copy:
    hg clone http://hg.openjdk.java.net/openjfx/9/rt/ jfx
    (or hg clone http://hg.openjdk.java.net/openjfx/9-dev/rt/ jfx which is slighly ahead)
  10. Set up some environment variables:
    Still in the console:
    set GRADLE_HOME=C:\dev\gradle-2.11
    set JAVA_HOME=C:\Program Files\Java\jdk-9
    set PATH=%PATH%;%JAVA_HOME%\bin;%GRADLE_HOME%\bin;%USERPROFILE%\.babun\cygwin\bin


  11. Build:
    Still in the console:
    cd jfx
    gradle
  12. Build the JDK (see the full instructions)

  13. In the console that built OpenJFX:
    set JIGSAW_HOME=C:\dev\jdk9\build\windows-x86_64-normal-server-release\images\jdk

    gradle apps
    then
    %JIGSAW_HOME%\bin\java -jar C:\dev\jfx-jake\apps\samples\Ensemble8\dist\Ensemble8.jar
  14. Hack...

Using Babun seems to take care of the Cygwin packages that are needed by OpenJFX, those that may not be already installed may be added using:
pact install  <package name>
(an exception being g++: mingw64-x86_64-gcc-g++ )

Thursday, 14 May 2015

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
      • uncheck all the options
      • or download AdminDeployment.xml to C:\dev\temp then start the installation with:
        vs_community.exe /AdminFile C:\dev\temp\AdminDeployment.xml
    3. Add the path to MSBuild to the PATH environement variable (required to build Freetype):
      C:\Program Files (x86)\MSBuild\12.0\Bin
  3. Download and install the Mercurial for Windows 
  4. Download and install Java 8 (if not already done)
  5. Download and install Babun, then use its package manager to install zip :
    pact install zip
  6. Download Freetype source (2.5.5) and extract to C:\dev\freetype-2.5.5
  7. In the Babun console:
    cd /cygdrive/c/dev
  8. Get the root source:
    hg clone http://hg.openjdk.java.net/jdk9/jdk9/
     (or the more bleeding edge http://hg.openjdk.java.net/jdk9/dev/ )
  9. Move to the new directory
    cd /cygdrive/c/dev/jdk9
  10. Get the remainder of the source
    ./get_source.sh 
  11. Force the permissions
    chmod -R u+rwxs .
    (otherwise some files get access denied errors)
  12. Run the auto-conf script
    bash configure --with-freetype-src=/cygdrive/c/dev/freetype-2.5.5
  13. Time for cooking
    make images
  14. Once done, open a new standard Windows console and navigate to
    C:\dev\jdk9\build\windows-x86_64-normal-server-release\images\jdk
    check that java runs:
    bin\java -version
    or for something a bit more visual:
    bin\jconsole
  15. enjoy!
For day to day refresh do the following (in the Babun shell):
  1. Go to the JDK directory
    cd /cygdrive/c/dev/jdk9
  2. Get the sources updates
    ./get_source.sh
  3. Force the permissions
    chmod -R u+rwxs .
  4. Remove the build directory
    rm -rf build/
  5. Rerun the auto-conf script to update the time stamp of the build:
    bash configure --with-freetype-src=/cygdrive/c/dev/freetype-2.5.5
  6. Re-heat
    make images

Thursday, 5 February 2015

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.
Since I first wrote this post the NetBeans team started their work for supporting JDK 9, check the NetBeans JDK 9 support wiki page for more.

For now the following seem to work for me:
  • define a JDK 9 platform
  • class indexation and autocompletion
  • run
I tested with an own build jdk9/jdk9 (so it should also work with a recent JDK9 early access build)

To try with your own NetBeans build:
  1. Download the diff (view)
  2. Import it with Mercurial
To run NetBeans with JDK 9 yet develop for it, add the following lines to <nb working copy>/nbbuild/user.build.properties :
nbjdk.home=C:\\Program Files\\Java\\jdk1.7.0_76
# if nbjdk.home is pointing to a JDK8 then uncomment:
#permit.jdk8.builds=true
To launch an instance of NetBeans running JDK 9 via NetBeans, in <nb working copy>/nbbuild/build.xml, for the tryme target, change the value of the <arg file="${nbjdk.home}"/> of the exec task to the path to JDK9

Explore!