Monday, 30 August 2010

Jigsaw: WorldClock with Maven

In the previous post I built WorldClock using just the command line, this time I'll use Maven for compiling.

1. Get Maven
sudo apt-get install maven2
Set JAVA_HOME to Jigsaw, so that Maven uses Jigsaw:
export JAVA_HOME=~/dev/jigsaw/build/linux-i586/jdk-module-image


2. Adjusting the paths for Maven
Create new directories:
mkdir -p ~/dev/worldclock/panel/src/main/java

mkdir -p ~/dev/worldclock/application/src/main/java

Move the files:
mv /home/ludovic/dev/worldclock/panel/src/lh.worldclock.panel ~/dev/worldclock/panel/src/main/java
mv /home/ludovic/dev/worldclock/panel/resources ~/dev/worldclock/panel/src/main/

mv /home/ludovic/dev/worldclock/application/src/lh.worldclock.panel ~/dev/worldclock/application/src/main/java
mv /home/ludovic/dev/worldclock/application/resources ~/dev/worldclock/application/src/main/

3. Add the poms



Panel ( gedit ~/dev/worldclock/panel/pom.xml & ):

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>lh.worldclock</groupId>
  <artifactId>panel</artifactId>
  <packaging>jar</packaging>
  <version>0.7-SNAPSHOT</version>
  <name>Worldclock Panel</name>
  <url>https://worldclock-application.dev.java.net/</url>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Application ( gedit ~/dev/worldclock/application/pom.xml & ):

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>lh.worldclock</groupId>
  <artifactId>application</artifactId>
  <packaging>jar</packaging>
  <version>0.7-SNAPSHOT</version>
  <name>Worldclock Application</name>
  <url>https://worldclock-application.dev.java.net/</url>
  <dependencies>
    <dependency>
      <groupId>lh.worldclock</groupId>
      <artifactId>panel</artifactId>
      <version>0.7-SNAPSHOT</version>
    </dependency>
  </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArguments>
                        <version />
                        <L>../modules</L>
                    </compilerArguments>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
(somehow using <compilerArgument> -L ../modules</compilerArgument> does not work)

4. Recreate the library
rm -rf ~/dev/worldclock/modules
$JIG/bin/jmod create -L ~/dev/worldclock/modules
 5. Compile and add to the library
Panel:
cd ~/dev/worldclock/panel

mvn install

$JIG/bin/jmod -L ~/dev/worldclock/modules install ~/dev/worldclock/panel/build -r ~/dev/worldclock/panel/src/main/resources lh.worldclock.panel
Application:
cd ~/dev/worldclock/application

mvn install

$JIG/bin/jmod -L ~/dev/worldclock/modules install ~/dev/worldclock/application/build -r ~/dev/worldclock/application/resources lh.worldclock.application
6. Run
$JIG/bin/java -L ~/dev/worldclock/modules -m lh.worldclock.application

Sunday, 2 May 2010

Jigsaw: From Hello World to WorldClock

(last updated 2010-06-20)

Moving on from Hello World to WorldClock, a simple multimodules application.

1. Get the source
Install Subversion:
sudo apt-get install subversion
Create the directories:
mkdir -p ~/dev/worldclock
 Get the source:
cd ~/dev/worldclock
svn checkout https://worldclock-application.dev.java.net/svn/worldclock-application/tags/application6-jigsaw ~/dev/worldclock/application --username guest
When prompted for guest password just press enter, Gnome keyring application then pops up, just cancel and say yes to store the password unencrypted.

2. Move the source files arround
Create the additional directories:
mkdir -p ~/dev/worldclock/application/attic
mkdir -p ~/dev/worldclock/application/build
mkdir -p ~/dev/worldclock/application/resources/lh/worldclock
mkdir -p ~/dev/worldclock/application/src/lh.worldclock.application

mkdir -p ~/dev/worldclock/panel/build
mkdir -p ~/dev/worldclock/panel/resources/lh/worldclock/core
mkdir -p ~/dev/worldclock/panel/src/lh.worldclock.panel/lh/worldclock
(attic is only used to store existing files that won't be needed)

Then move the files:
mv ~/dev/worldclock/application/*.* ~/dev/worldclock/application/attic
mv ~/dev/worldclock/application/src/META-INF ~/dev/worldclock/application/attic

mv ~/dev/worldclock/application/src/lh ~/dev/worldclock/application/src/lh.worldclock.application

mv ~/dev/worldclock/application/src/lh.worldclock.application/lh/worldclock/core ~/dev/worldclock/panel/src/lh.worldclock.panel/lh/worldclock

mv ~/dev/worldclock/application/src/lh.worldclock.application/lh/worldclock/*.properties ~/dev/worldclock/application/resources/lh/worldclock
mv ~/dev/worldclock/application/src/lh.worldclock.application/lh/worldclock/*.png ~/dev/worldclock/application/resources/lh/worldclock

mv ~/dev/worldclock/panel/src/lh.worldclock.panel/lh/worldclock/core/*.jpg ~/dev/worldclock/panel/resources/lh/worldclock/core
The tree should look like this:
So we now have 2 subprojects: application and panel
Each composed of 3 areas: build, src and resources

3. Add the Jigsaw layer
The first part is already there, the first level of subdirectories in the src directories represents the modules roots.

Next add the module-info file for lh.worldclock.panel:
( gedit ~/dev/worldclock/panel/src/lh.worldclock.panel/module-info.java & )
module lh.worldclock.panel @ 0.7
{
  requires jdk.desktop;
}
And the module-info file for lh.worldclock.application:
( gedit ~/dev/worldclock/application/src/lh.worldclock.application/module-info.java & )
module lh.worldclock.application @ 0.7
{
  requires jdk.desktop;
  requires lh.worldclock.panel @ 0.7;
  class lh.worldclock.WorldClock;
}
4. Create the library
$JIG/bin/jmod create -L ~/dev/worldclock/modules
 5. Compile and add to the library
Panel:
cd ~/dev/worldclock/panel

$JIG/bin/javac -encoding UTF-8 -source 7 -d build src/lh.worldclock.panel/module-info.java src/lh.worldclock.panel/lh/worldclock/core/WorldClockBoard.java

$JIG/bin/jmod -L ~/dev/worldclock/modules install ~/dev/worldclock/panel/build -r ~/dev/worldclock/panel/resources lh.worldclock.panel
Application:
cd ~/dev/worldclock/application

$JIG/bin/javac -L ../modules -source 7 -d build src/lh.worldclock.application/module-info.java src/lh.worldclock.application/lh/*/*.java

$JIG/bin/jmod -L ~/dev/worldclock/modules install ~/dev/worldclock/application/build -r ~/dev/worldclock/application/resources lh.worldclock.application
6. Run
$JIG/bin/java -L ~/dev/worldclock/modules -m lh.worldclock.application

Sunday, 7 March 2010

Hello World module with Jigsaw

Following my building Jigsaw post, here are the instructions for a Hello World module:

1. Create the project structure

mkdir -p ~/dev/hello/src/hello/lh/hello
mkdir -p ~/dev/hello/build

2. Create the Main class
use: gedit ~/dev/hello/src/hello/lh/hello/Main.java & 
package lh.hello;

public class Main
{
  public static void main(String[] args)
  {
    System.out.println("Hello Jigsaw!!");
  }
}

3. Create the module descriptor
use gedit ~/dev/hello/src/hello/module-info.java &
module hello @ 1.0
{
  class lh.hello.Main;
}

4. Compile
In ~/dev/hello :
$JIG/bin/javac -source 7 -d build src/hello/module-info.java src/hello/lh/hello/Main.java

5. Create a private modules library
Create a private library so that the module can be removed easily. The private library parent defaults to the JDK library.
In ~/dev/hello :
 $JIG/bin/jmod create -L modules

6. Install the hello module
In ~/dev/hello :
 $JIG/bin/jmod install -L modules build hello

7. Run
In ~/dev/hello :
$JIG/bin/java -L modules -m hello
prints:
Hello Jigsaw!!

Sunday, 7 February 2010

Devoxx 09 Summary

(somehow I forgot about this post, time has passed and my comments are mostly lost in memory)

Devoxx 09 Summary


Conference Day 1

Wednesday November 18th


9:30-11:30      Keynote
12:00-13:00    JDK7 Update
13:30-13:45    Swing & OSGi - please play nice
14:00-15:00    James Gosling on the JavaStore
15:10-16:10    JavaFX
16:40-17:40   
17:50-18:50    Project Coin
19:00-20:00    Java User Group BOF
20:00-             (mostly) French evening

Conference Day 2

Thursday November 19th


9:30-11:30     Keynote (both interresting: fashion and say no)
12:00-13:00   Do you really get class loaders? (should watch)
14:00-15:00   Pro JavaFX - Developing Enterprise Applications (thanks Steven)
15:10-16:10   The JavaPosse.com Live
16:40-17:40   Detecting and preventing bugs with pluggable type-checking (useful, but not exiting)
17:50-18:50   The Modular Java Platform & Project Jigsaw
19:00-20:00   JavaFX Future (next time, review JavaFX and practice a little again before going)
20:00-            (mostly) JavaFX evening

Conference Day 3

Friday November 20th


9:30-10:30     Gaming JavaFX
10:30-11:30   Tapestry 5
11:30-12:30   Project Lombok: Bye Bye Boilerplate

Sunday, 15 November 2009

Building Jigsaw

Last updated: 2013-07-27

In preparation for Devoxx 09, I wanted to play a little with Jigsaw.
Thereafter are the few steps I have followed to build it (based on the build readme for Jigsaw but revised each time I build Jigsaw):


1. Create a new Ubuntu VM in VirtualBox
To download VirtualBox go here and to download Ubuntu (12.04 LTS or 13.04) go there.
I used 2Gb of RAM and 16 Gb of disk. (don't forget to install the guest additions and get the updates for Ubuntu)


2. Get and setup Mercurial
Open a console (Applications|Accessories|Terminal), type:
sudo apt-get install mercurial

3. Download and install the current build dependencies for OpenJDK7

sudo apt-get build-dep  openjdk-7

4. Download and install the current JDK7

sudo apt-get install openjdk-7-jdk

5. Download and install ccache
 This will speed up the build of native parts
sudo apt-get install ccache

6. Get Jigsaw sources
mkdir ~/dev
cd ~/dev/
hg clone http://hg.openjdk.java.net/jigsaw/jigsaw/ jigsaw
cd ~/dev/jigsaw/
chmod u+x get_source.sh
./get_source.sh

7. Set up the environement variablesSource encoding:

export LANG=C

8. Adjustments
2013-07-27, none.

9.  Configure
make sure to be in ~/dev/jigsaw and run:
cd ~/dev/jigsaw
bash configure

10.  make
time for cooking:
make images

11. post-build
Export a JIG enviroment variable to prefix your java commands and so use Jigsaw rather than the default openjdk:
64 bits vm:
export JIG=~/dev/jigsaw/build/linux-x86_64-normal-server-release/images/jdk-module-image/
or
32 bits vm:
 export JIG=~/dev/jigsaw/build/linux-x86-normal-server-release/images/jdk-module-image/
12. running Jigsaw?

$JIG/bin/java -version
should return something like:
openjdk version "1.8.0-internal"
OpenJDK Runtime Environment (build 1.8.0-internal-ludovic_2013_07_27_19_55-b00)
OpenJDK 64-Bit Server VM (build 25.0-b30, mixed mode)
and
$JIG/bin/jmod list -v
should return something like:
jdk@8-ea
  requires jdk.base@=8-ea
  requires public jdk.jre@=8-ea
  requires public jdk.tools@=8-ea

...

jdk.base@8-ea
  requires local optional jdk.desktop.internal@=8-ea
  requires optional jdk.jaxp@=8-ea
  requires local optional jdk.tls.internal@=8-ea
  requires local optional sun.charsets@=8-ea
  requires local optional sun.localedata@=8-ea
  requires local optional sun.resources@=8-ea
  provides java.base@8
  exports
    com.sun.nio.file
    com.sun.security.auth
    com.sun.security.auth.login
    java.beans
    java.io
    java.lang
    java.lang.annotation
    java.lang.invoke
    java.lang.module

...
running Jigsaw modules:

JPS:
$JIG/bin/java -m jdk.jps
or JConsole:
$JIG/bin/java -m jdk.jconsole
 Now is time to play...

Friday, 13 November 2009

Devoxx 09

Devoxx 09

forseen schedule

Conference Day 1

Wednesday November 18th


9:30-11:30      Keynote
12:00-13:00    JDK7 Update
13:30-13:45    quickie OSGi Testing Pax Exam or Swing & OSGi - please play nice
14:00-15:00     James Gosling
15:10-16:10     JavaFX or The Java EE 6 Platform
16:40-17:40    ?
17:50-18:50    Project Coin or Animation Rules!
19:00-20:00    Java User Group BOF ?
20:00-21:00    Update JDK7

Conference Day 2

Thursday November 19th


9:30-11:30     Keynote
12:00-13:00   Using XML with Java: Spoilt for Choice? or Spring Framework 3.0
13:30-13:45   ?
14:00-15:00   Pro JavaFX - Developing Enterprise Applications
15:10-16:10   The JavaPosse.com Live
16:40-17:40   Detecting and preventing bugs with pluggable type-checking or Funky Java, Objective Scala or Deep dive on the Java EE 6 platform with GlassFish V3
17:50-18:50   The Modular Java Platform & Project Jigsaw or Maven Reloaded
19:00-20:00   JavaFX Futures
20:00-21:00   The Modular Java Platform and Project JigSaw ?
21:00-22:00   Maven3 BOF
or 2012 ?

Conference Day 3

Friday November 20th


9:30-10:30     Gaming JavaFX or Java and JavaFX Technology and the Nintendo Wiimote: Just How Much Fun Can You Have?
10:30-11:30   Towards A Universal VM or Modular Web Applications with OSGi
11:30-12:30    Project Lombok: Bye Bye Boilerplate

Sunday, 11 January 2009

Worldclock 0.3 widget for WidgetFX 1.0

After a few issues upgrading to JavaFX 1.0 / WidgetFX 1.0 (the SwingComponent.wrap() does not quite do exactly the same thing as the old Component.fromJComponent(), at least for me the resize does not work exactly the same), I've released version 0.3 of the Worldclock widget.
Also in this release the possibility to enforce the aspect ratio of the world image(s).

Web page: https://worldclock-application.dev.java.net/#Widget
Direct launch: http://widgetfx.org/dock/launch.jnlp?arg=https://worldclock-application.dev.java.net/widget-webstart/launch.jnlp

Enjoy,