Adam Bien's Weblog

Monday Feb 06, 2012

Setting JavaFX 2 Runtime At Start (And Solving "Unable to read ../rt/" Problem)

If you run "java -jar killer-app.jar" on a machine where JavaFX SDK was installed with a simple "unzip" (like a Mac), you will get the following error:


Unable to read ../rt/lib/jfxrt.jar
Unable to read ../../../../rt/lib/jfxrt.jar
Unable to read ../../sdk/rt/lib/jfxrt.jar
Unable to read ../../../artifacts/sdk/rt/lib/jfxrt.jar

Because the Java FX launcher does not know where to find the runtime, it falls back to the default location.
To solve this problem, just pass the system property: javafx.runtime.path with the JavaFX SDK location at start:

java -Djavafx.runtime.path=[THE UNZIPPED JAVA FX SDK]/rt -jar killer-app.jar



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Friday Jan 13, 2012

JavaFX 2.0 CSS Reference

All JavaFX 2 components can be styled with CSS 3. The CSS JavaFX 2 reference is available here: http://docs.oracle.com/javafx/2.0/api/javafx/scene/doc-files/cssref.html. To activate your custom CSS you only have to add a resource containing the CSS styles to the javafx.scene.Scene:


        Scene scene = ...
        scene.getStylesheets().add(this.getClass().getResource("javafxrocks.css").toExternalForm());
        stage.setScene(scene);
        stage.show();



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Wednesday Dec 21, 2011

How To Compile Java FX 2 Applications With Maven 3

Java FX 2 is Java. To build a Java FX application you only need an additional JAR: jfxrt.jar which contains the Java FX UI classes. The JAR comes with Java FX SDK, but is not included in the public maven repository. You can point to the Java FX SDK installation with Maven's system scope dependency:


<project>
...
    <dependencies>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>javafx</artifactId>
            <version>2.0</version>
            <systemPath>${fx.home}/rt/lib/jfxrt.jar</systemPath>
            <scope>system</scope>
        </dependency>
    </dependencies>
</project>

The resolution of the ${fx.home} variable ensures the pom.xml independency on user-specific settings:

<settings>
...
<profiles>
        <profile>
            <id>javafx</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <fx.home>[PATH]/javafx-sdk2.1.0-beta/</fx.home>
            </properties>
        </profile>
    </profiles>
</settings>



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Monday Dec 19, 2011

Java FX 2 …Comes With Java SE 7 Update 2

Java FX 2 is shipped now with Java SE. This update makes Java FX 2 a default choice for RIAs on the Java platform.

You can download Java SE 7 Update 2 from here.



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Monday Jul 18, 2011

Swing Looks ...Great!: NetBeans 7 (IDE + RCP) With New Synthetica L&F

Synthetica V2.13 and SyntheticaAddons V1.5 L&Fs for Swing are released. See also NetBeans RCP with Synthetica L&F.
Some screenshots with NetBeans 7 IDE with Synthetica L&F:





*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Thursday Mar 10, 2011

Swing Looks ...Great! - New Theme For Synthetica

The BlackEye look and feel was already introduced. Synthetica comes with a new theme called "Classy":



WebStart Demo works perfectly on MacOS X. Its not a trick - its Swing :-).



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Monday Feb 21, 2011

Hello JavaFX 2! - A TableView Component

A table control was missed in JavaFX 1.3. JavaFX 2 comes with a new table component:

import javafx.application.Application;
import javafx.application.Launcher;
import javafx.collections.FXCollections;
import javafx.collections.Sequence;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.table.TableColumn;
import javafx.scene.control.table.TableView;
import javafx.scene.control.table.model.SequenceTableModel;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start() {

        Stage stage = new Stage();
        stage.setTitle("Hello Table");

        final Group root = new Group();
        Scene scene = new Scene(root);
        stage.setScene(scene);

        Sequence children = root.getChildren();
        children.add(getTableView());
        stage.setVisible(true);
    }

 	//TableView is a node...
    public static Node getTableView() {

        Sequence data = fetchDataFromServer();

        TableView tableView = new TableView();
        SequenceTableModel tableModel = new SequenceTableModel(data);
        tableView.setModel(tableModel);

        TableColumn[] columns = buildColumns(data);
        tableView.getColumns().addAll(columns);
        return tableView;
    }

    //sequence is an Observable java.util.List. It could come directly from e.g. JPA EntityManager.
    public static Sequence fetchDataFromServer() {
        return FXCollections.sequence(
                new Person("Duke", "Java"),
                new Person("DukeFX", "JavaFX"));

    }

    public static TableColumn[] buildColumns(final Sequence data) {
        TableColumn firstNameCol = new TableColumn();
        firstNameCol.setText("First");
        firstNameCol.setGetCellData(new TableColumn.GetCellData() {

            @Override
            public Object get(long row, int col) {
                return data.get((int) row).getFirstName();
            }
        });

        TableColumn lastNameCol = new TableColumn();
        lastNameCol.setText("Last");
        lastNameCol.setGetCellData(new TableColumn.GetCellData() {

            @Override
            public Object get(long row, int col) {
                return data.get((int) row).getLastName();
            }
        });

        return new TableColumn[]{firstNameCol, lastNameCol};

    }

    public static void main(String[] args) {
        Launcher.launch(Main.class, args);
    }
}


public class Person {

    private String firstName;
    private String lastName;

    public Person(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }
//with getters.
}

A similar example comes with JavaFX 2 already. I just decomposed the origin example in several methods to see what happens behind the scenes.
Java FX 2 application can be compiled having jfxrt.jar in the classpath and launched like any other Java application: java -cp javafx-sdk2.0-ea/rt/jfxrt.jar com.abien.table.Main
Even in the case of the preview the startup performance is <1 sec and significantly faster, than 1.X version.
This post is based on Java FX 2 Early Access - the API and runtime can change any time.
Sees official JavaFX roadmap for more details.



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Monday Feb 14, 2011

Hello JavaFX 2! - Back To Java

In contrary to JavaFX 1.X, JavaFX 2 is pure Java:


package com.abien.hello;

import javafx.application.Application;
import javafx.application.Launcher;
import javafx.collections.Sequence;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;

public class Main extends Application{


    @Override public void start() {
        Stage stage = new Stage();
        stage.setTitle("Hello Java FX");
        stage.setResizable(false);

        Group root = new Group();
        Scene scene = new Scene(root,80,20);
        stage.setScene(scene);

        Sequence children = root.getChildren();
        children.add(new Label("Hello Java FX 2"));
        stage.setVisible(true);

    }

    public static void main(String[] args) {
        Launcher.launch(Main.class, args);
    }
}

Java FX 2 application can be compiled having jfxrt.jar in the classpath and launched like any other Java application: java -cp javafx-sdk2.0-ea/rt/jfxrt.jar com.abien.hello.Main
Even in the case of the preview the startup performance is <1 sec and significantly faster, than 1.X version.
This post is based on Java FX 2 Early Access - the API and runtime can change any time.
Sees official JavaFX roadmap for more details.



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Friday Feb 04, 2011

Java FX 2.0 - The Installation, Doc and Launch Experience - A Smoke Test

The installation of Java FX 2.0 is as simple as it can get - unzip of the Early Access was sufficient.

First observations:
  1. Startup of the provided examples is extremely fast < 1 sec and orders of magnitude faster than previous Java FX 1.3 samples
  2. A double click on a Jar-file is sufficient to launch a Java FX app - no further configuration was necessary
  3. The doc comes in fresh design and is compelling
  4. Java FX 2.0 is extremely easy to integrate with Java projects - the inclusion of a single Jar is sufficient
  5. The runtime is far smaller, than expected

The first impression of the Java FX 2.0 Early Access is far better, than expected so far...



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Friday Jun 25, 2010

Java FX CSS Reference Available

The appearance of UI-Controls in Java FX can be either configured programmatically, or with CSS. See this comprehensive CSS reference. Hopefully it will be distributed with the official SDK doc in the next release...
Its a kind of "Convention Over Configuration" again :-).



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Meta
My Recent Book
Java One 2009/2011
...the last 150 posts
...the last 10 comments
Links
License

Adam Bien's Weblog

Monday Feb 06, 2012

Setting JavaFX 2 Runtime At Start (And Solving "Unable to read ../rt/" Problem)

If you run "java -jar killer-app.jar" on a machine where JavaFX SDK was installed with a simple "unzip" (like a Mac), you will get the following error:


Unable to read ../rt/lib/jfxrt.jar
Unable to read ../../../../rt/lib/jfxrt.jar
Unable to read ../../sdk/rt/lib/jfxrt.jar
Unable to read ../../../artifacts/sdk/rt/lib/jfxrt.jar

Because the Java FX launcher does not know where to find the runtime, it falls back to the default location.
To solve this problem, just pass the system property: javafx.runtime.path with the JavaFX SDK location at start:

java -Djavafx.runtime.path=[THE UNZIPPED JAVA FX SDK]/rt -jar killer-app.jar



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Friday Jan 13, 2012

JavaFX 2.0 CSS Reference

All JavaFX 2 components can be styled with CSS 3. The CSS JavaFX 2 reference is available here: http://docs.oracle.com/javafx/2.0/api/javafx/scene/doc-files/cssref.html. To activate your custom CSS you only have to add a resource containing the CSS styles to the javafx.scene.Scene:


        Scene scene = ...
        scene.getStylesheets().add(this.getClass().getResource("javafxrocks.css").toExternalForm());
        stage.setScene(scene);
        stage.show();



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Wednesday Dec 21, 2011

How To Compile Java FX 2 Applications With Maven 3

Java FX 2 is Java. To build a Java FX application you only need an additional JAR: jfxrt.jar which contains the Java FX UI classes. The JAR comes with Java FX SDK, but is not included in the public maven repository. You can point to the Java FX SDK installation with Maven's system scope dependency:


<project>
...
    <dependencies>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>javafx</artifactId>
            <version>2.0</version>
            <systemPath>${fx.home}/rt/lib/jfxrt.jar</systemPath>
            <scope>system</scope>
        </dependency>
    </dependencies>
</project>

The resolution of the ${fx.home} variable ensures the pom.xml independency on user-specific settings:

<settings>
...
<profiles>
        <profile>
            <id>javafx</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <fx.home>[PATH]/javafx-sdk2.1.0-beta/</fx.home>
            </properties>
        </profile>
    </profiles>
</settings>



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Monday Dec 19, 2011

Java FX 2 …Comes With Java SE 7 Update 2

Java FX 2 is shipped now with Java SE. This update makes Java FX 2 a default choice for RIAs on the Java platform.

You can download Java SE 7 Update 2 from here.



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Monday Jul 18, 2011

Swing Looks ...Great!: NetBeans 7 (IDE + RCP) With New Synthetica L&F

Synthetica V2.13 and SyntheticaAddons V1.5 L&Fs for Swing are released. See also NetBeans RCP with Synthetica L&F.
Some screenshots with NetBeans 7 IDE with Synthetica L&F:





*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Thursday Mar 10, 2011

Swing Looks ...Great! - New Theme For Synthetica

The BlackEye look and feel was already introduced. Synthetica comes with a new theme called "Classy":



WebStart Demo works perfectly on MacOS X. Its not a trick - its Swing :-).



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Monday Feb 21, 2011

Hello JavaFX 2! - A TableView Component

A table control was missed in JavaFX 1.3. JavaFX 2 comes with a new table component:

import javafx.application.Application;
import javafx.application.Launcher;
import javafx.collections.FXCollections;
import javafx.collections.Sequence;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.table.TableColumn;
import javafx.scene.control.table.TableView;
import javafx.scene.control.table.model.SequenceTableModel;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start() {

        Stage stage = new Stage();
        stage.setTitle("Hello Table");

        final Group root = new Group();
        Scene scene = new Scene(root);
        stage.setScene(scene);

        Sequence children = root.getChildren();
        children.add(getTableView());
        stage.setVisible(true);
    }

 	//TableView is a node...
    public static Node getTableView() {

        Sequence data = fetchDataFromServer();

        TableView tableView = new TableView();
        SequenceTableModel tableModel = new SequenceTableModel(data);
        tableView.setModel(tableModel);

        TableColumn[] columns = buildColumns(data);
        tableView.getColumns().addAll(columns);
        return tableView;
    }

    //sequence is an Observable java.util.List. It could come directly from e.g. JPA EntityManager.
    public static Sequence fetchDataFromServer() {
        return FXCollections.sequence(
                new Person("Duke", "Java"),
                new Person("DukeFX", "JavaFX"));

    }

    public static TableColumn[] buildColumns(final Sequence data) {
        TableColumn firstNameCol = new TableColumn();
        firstNameCol.setText("First");
        firstNameCol.setGetCellData(new TableColumn.GetCellData() {

            @Override
            public Object get(long row, int col) {
                return data.get((int) row).getFirstName();
            }
        });

        TableColumn lastNameCol = new TableColumn();
        lastNameCol.setText("Last");
        lastNameCol.setGetCellData(new TableColumn.GetCellData() {

            @Override
            public Object get(long row, int col) {
                return data.get((int) row).getLastName();
            }
        });

        return new TableColumn[]{firstNameCol, lastNameCol};

    }

    public static void main(String[] args) {
        Launcher.launch(Main.class, args);
    }
}


public class Person {

    private String firstName;
    private String lastName;

    public Person(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }
//with getters.
}

A similar example comes with JavaFX 2 already. I just decomposed the origin example in several methods to see what happens behind the scenes.
Java FX 2 application can be compiled having jfxrt.jar in the classpath and launched like any other Java application: java -cp javafx-sdk2.0-ea/rt/jfxrt.jar com.abien.table.Main
Even in the case of the preview the startup performance is <1 sec and significantly faster, than 1.X version.
This post is based on Java FX 2 Early Access - the API and runtime can change any time.
Sees official JavaFX roadmap for more details.



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Monday Feb 14, 2011

Hello JavaFX 2! - Back To Java

In contrary to JavaFX 1.X, JavaFX 2 is pure Java:


package com.abien.hello;

import javafx.application.Application;
import javafx.application.Launcher;
import javafx.collections.Sequence;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;

public class Main extends Application{


    @Override public void start() {
        Stage stage = new Stage();
        stage.setTitle("Hello Java FX");
        stage.setResizable(false);

        Group root = new Group();
        Scene scene = new Scene(root,80,20);
        stage.setScene(scene);

        Sequence children = root.getChildren();
        children.add(new Label("Hello Java FX 2"));
        stage.setVisible(true);

    }

    public static void main(String[] args) {
        Launcher.launch(Main.class, args);
    }
}

Java FX 2 application can be compiled having jfxrt.jar in the classpath and launched like any other Java application: java -cp javafx-sdk2.0-ea/rt/jfxrt.jar com.abien.hello.Main
Even in the case of the preview the startup performance is <1 sec and significantly faster, than 1.X version.
This post is based on Java FX 2 Early Access - the API and runtime can change any time.
Sees official JavaFX roadmap for more details.



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Friday Feb 04, 2011

Java FX 2.0 - The Installation, Doc and Launch Experience - A Smoke Test

The installation of Java FX 2.0 is as simple as it can get - unzip of the Early Access was sufficient.

First observations:
  1. Startup of the provided examples is extremely fast < 1 sec and orders of magnitude faster than previous Java FX 1.3 samples
  2. A double click on a Jar-file is sufficient to launch a Java FX app - no further configuration was necessary
  3. The doc comes in fresh design and is compelling
  4. Java FX 2.0 is extremely easy to integrate with Java projects - the inclusion of a single Jar is sufficient
  5. The runtime is far smaller, than expected

The first impression of the Java FX 2.0 Early Access is far better, than expected so far...



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Friday Jun 25, 2010

Java FX CSS Reference Available

The appearance of UI-Controls in Java FX can be either configured programmatically, or with CSS. See this comprehensive CSS reference. Hopefully it will be distributed with the official SDK doc in the next release...
Its a kind of "Convention Over Configuration" again :-).



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Meta
My Recent Book
Java One 2009/2011
...the last 150 posts
...the last 10 comments
Links
License