-
Bug
-
Resolution: Not an Issue
-
P2
-
None
-
8u40
-
Windows 7 64bit
With jdk 8u40 b18 there is a problem showing the Preloader. The toolkit exits prematurely.
This is the code of the preloader:
public class SplashScreenUi extends Preloader {
private final Logger log = Logger.getLogger(SplashScreenUi.class);
@FXML
ProgressBar progressBar;
Stage stage;
boolean noLoadingProgress = false;
private Scene createPreloaderScene() {
try {
AnchorPane root = FXMLLoader.load(SplashScreenUi.class.getResource("SplashScreenUi.fxml"));
for (Node node : root.getChildren()) {
if (node instanceof ProgressBar) {
progressBar = (ProgressBar) node;
progressBar.setProgress(-1);
// progressBar.setVisible(false);
}
}
Scene scene = new Scene(root);
scene.setFill(Color.TRANSPARENT);
return scene;
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
public void start(Stage stage) throws Exception {
log.debug("--->SPLASH SCREEN<-----");
this.stage = stage;
if (stage != null) {
stage.initStyle(StageStyle.TRANSPARENT);
stage.setScene(createPreloaderScene());
stage.centerOnScreen();
stage.show();
log.debug("Showing: " + stage.isShowing() + " iconified: " + stage.isIconified());
}
}
@Override
public void handleStateChangeNotification(StateChangeNotification evt) {
// ignore, hide after application signals it is ready
if (evt.getType() == StateChangeNotification.Type.BEFORE_START) {
FadeTransition ft = new FadeTransition(Duration.millis(1000), stage.getScene().getRoot());
ft.setFromValue(1.0);
ft.setToValue(0.0);
EventHandler<ActionEvent> eh = new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
System.out.println("Nascondo lo Splash Screen");
stage.hide();
}
};
ft.setOnFinished(eh);
ft.play();
}
}
}
In the main class I tried both with workaround suggested inRT-36851 either without:
public static void main(String[] args) {
Locale.setDefault(Locale.ITALIAN);
//Application.launch(Main.class, args);
/**
* WORKAROUND PER FAR FUNZIONARE LO SPLASH SCREEN ANCHE CON I PACKAGE
* NATIVI Aperto bug https://javafx-jira.kenai.com/browse/RT-38432 e
* https://sviluppo.pianetatecno.com/issues/185
*/
com.sun.javafx.application.LauncherImpl.launchApplication(Main.class, SplashScreenUi.class, args);
}
And this is the build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="app-desk" default="do-deploy" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<property name="java8.jdk.home" value="C:\Programmi\Java\jdk1.8.0_40\" />
<property name="javafx.tools.ant.jar" value="${java8.jdk.home}\lib\ant-javafx.jar" />
<target name="init-fx-tasks">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath=".:${javafx.tools.ant.jar}" />
</target>
<target name="setup-staging-area">
<delete dir="externalLibs" />
<delete dir="project" />
<mkdir dir="externalLibs" />
<!--LIBRERIE PERSONALIZZATE-->
<copy todir="externalLibs">
<fileset dir=".">
<exclude name="app*" />
<include name="**.jar" />
</fileset>
</copy>
<mkdir dir="project" />
<copy todir="project">
<fileset dir="generated-sources">
<include name="gfx/**" />
</fileset>
</copy>
<copy todir="project">
<fileset dir="..\src\main">
<include name="resources/**" />
</fileset>
</copy>
<copy todir="project">
<fileset dir="..\src\main">
<include name="java/**" />
</fileset>
</copy>
</target>
<target name='do-compile'>
<delete dir="build" />
<mkdir dir="build/src" />
<mkdir dir="build/libs" />
<mkdir dir="build/classes" />
<!-- Copy project-libs references -->
<copy todir="build/libs">
<fileset dir="externalLibs">
<include name="**.jar" />
</fileset>
</copy>
<!-- Copy project references -->
<!-- Copy project sources itself -->
<copy todir="build/src">
<fileset dir="project/gfx">
<include name="**/*" />
</fileset>
</copy>
<copy todir="build/src">
<fileset dir="project/resources">
<include name="**/*" />
</fileset>
</copy>
<copy todir="build/src">
<fileset dir="project/java">
<include name="**/*" />
</fileset>
</copy>
<javac fork="true" executable="${java8.jdk.home}\bin\javac.exe" includeantruntime="false" source="1.8" target="1.8" srcdir="build/src" destdir="build/classes" encoding="UTF-8">
<classpath>
<fileset dir="build/libs">
<include name="*" />
</fileset>
<filelist>
<file name="${java8.jdk.home}\jre\lib\ext\jfxrt.jar" />
</filelist>
</classpath>
</javac>
<!-- Copy over none Java-Files -->
<copy todir="build/classes">
<fileset dir="project/resources">
<exclude name="**/*.java" />
</fileset>
<fileset dir="project/java">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="do-deploy" depends="setup-staging-area, do-compile, init-fx-tasks">
<delete file="dist" />
<delete file="deploy" />
<mkdir dir="dist" />
<mkdir dir="dist/libs" />
<copy todir="dist/libs">
<fileset dir="externalLibs">
<include name="*" />
</fileset>
</copy>
<fx:resources id="appRes">
<fx:fileset dir="dist" includes="app.jar" />
<fx:fileset dir="dist" includes="libs/*" />
</fx:resources>
<fx:application id="fxApplication" name="appDesk" version="3.0" mainClass="it.pianetatecno.app.client.Main" preloaderclass="it.pianetatecno.app.client.ui.preloader.SplashScreenUi" toolkit="fx" />
<fx:jar destfile="dist/app.jar">
<fx:application refid="fxApplication" />
<fileset dir="build/classes">
</fileset>
<fx:resources refid="appRes" />
<manifest>
<attribute name="Implementation-Vendor" value="PianetaTecno" />
<attribute name="Implementation-Title" value="app Desk" />
<attribute name="Implementation-Version" value="3.0.0" />
</manifest>
</fx:jar>
<mkdir dir="deploy" />
<!-- Need to use ${basedir} because somehow the ant task is calculating the directory differently -->
<fx:deploy outdir="${basedir}/deploy" outfile="appDesk" nativeBundles="all" height="768" width="1024" verbose="true">
<fx:info title="app Desk" vendor="PianetaTecno" copyright="Copyright PianetaTecno. Tutti i diritti riservati" />
<fx:application refId="fxApplication" />
<fx:resources refid="appRes" />
<fx:preferences shortcut="true" install="true" menu="true" />
<fx:permissions elevated="true" />
<!-- Custom JVM setup for application -->
<fx:platform basedir="${java8.jdk.home}">
<fx:jvmarg value="-Xmx1024m" />
</fx:platform>
</fx:deploy>
</target>
</project>
When I try to run the native bundle on Windows I've this exception:
23/12/2014 10:41:49 DEBUG Main:? - stop()
23/12/2014 10:41:49 INFO ApacheAsyncTransport:54 - Starting Apache HttpAsyncClient transport...
23/12/2014 10:41:49 INFO ApacheAsyncTransport:54 - Apache HttpAsyncClient transport started.
23/12/2014 10:41:49 INFO WebSocketTransport:54 - Starting WebSocket transport...
23/12/2014 10:41:49 INFO WebSocketTransport:54 - WebSocket transport started.
23/12/2014 10:41:49 DEBUG AbstractPagedCollection:90 - create collection
23/12/2014 10:41:50 ERROR Main:? -
java.lang.IllegalStateException: Toolkit has exited
at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:333)
at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:307)
at com.sun.javafx.application.LauncherImpl.notifyCurrentPreloader(LauncherImpl.java:971)
at com.sun.javafx.application.LauncherImpl.notifyPreloader(LauncherImpl.java:983)
at javafx.application.Application.notifyPreloader(Application.java:369)
at it.pianetatecno.app.client.Main$GraniteSpringStartThread.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
This is the code of the preloader:
public class SplashScreenUi extends Preloader {
private final Logger log = Logger.getLogger(SplashScreenUi.class);
@FXML
ProgressBar progressBar;
Stage stage;
boolean noLoadingProgress = false;
private Scene createPreloaderScene() {
try {
AnchorPane root = FXMLLoader.load(SplashScreenUi.class.getResource("SplashScreenUi.fxml"));
for (Node node : root.getChildren()) {
if (node instanceof ProgressBar) {
progressBar = (ProgressBar) node;
progressBar.setProgress(-1);
// progressBar.setVisible(false);
}
}
Scene scene = new Scene(root);
scene.setFill(Color.TRANSPARENT);
return scene;
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
public void start(Stage stage) throws Exception {
log.debug("--->SPLASH SCREEN<-----");
this.stage = stage;
if (stage != null) {
stage.initStyle(StageStyle.TRANSPARENT);
stage.setScene(createPreloaderScene());
stage.centerOnScreen();
stage.show();
log.debug("Showing: " + stage.isShowing() + " iconified: " + stage.isIconified());
}
}
@Override
public void handleStateChangeNotification(StateChangeNotification evt) {
// ignore, hide after application signals it is ready
if (evt.getType() == StateChangeNotification.Type.BEFORE_START) {
FadeTransition ft = new FadeTransition(Duration.millis(1000), stage.getScene().getRoot());
ft.setFromValue(1.0);
ft.setToValue(0.0);
EventHandler<ActionEvent> eh = new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
System.out.println("Nascondo lo Splash Screen");
stage.hide();
}
};
ft.setOnFinished(eh);
ft.play();
}
}
}
In the main class I tried both with workaround suggested in
public static void main(String[] args) {
Locale.setDefault(Locale.ITALIAN);
//Application.launch(Main.class, args);
/**
* WORKAROUND PER FAR FUNZIONARE LO SPLASH SCREEN ANCHE CON I PACKAGE
* NATIVI Aperto bug https://javafx-jira.kenai.com/browse/RT-38432 e
* https://sviluppo.pianetatecno.com/issues/185
*/
com.sun.javafx.application.LauncherImpl.launchApplication(Main.class, SplashScreenUi.class, args);
}
And this is the build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="app-desk" default="do-deploy" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<property name="java8.jdk.home" value="C:\Programmi\Java\jdk1.8.0_40\" />
<property name="javafx.tools.ant.jar" value="${java8.jdk.home}\lib\ant-javafx.jar" />
<target name="init-fx-tasks">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath=".:${javafx.tools.ant.jar}" />
</target>
<target name="setup-staging-area">
<delete dir="externalLibs" />
<delete dir="project" />
<mkdir dir="externalLibs" />
<!--LIBRERIE PERSONALIZZATE-->
<copy todir="externalLibs">
<fileset dir=".">
<exclude name="app*" />
<include name="**.jar" />
</fileset>
</copy>
<mkdir dir="project" />
<copy todir="project">
<fileset dir="generated-sources">
<include name="gfx/**" />
</fileset>
</copy>
<copy todir="project">
<fileset dir="..\src\main">
<include name="resources/**" />
</fileset>
</copy>
<copy todir="project">
<fileset dir="..\src\main">
<include name="java/**" />
</fileset>
</copy>
</target>
<target name='do-compile'>
<delete dir="build" />
<mkdir dir="build/src" />
<mkdir dir="build/libs" />
<mkdir dir="build/classes" />
<!-- Copy project-libs references -->
<copy todir="build/libs">
<fileset dir="externalLibs">
<include name="**.jar" />
</fileset>
</copy>
<!-- Copy project references -->
<!-- Copy project sources itself -->
<copy todir="build/src">
<fileset dir="project/gfx">
<include name="**/*" />
</fileset>
</copy>
<copy todir="build/src">
<fileset dir="project/resources">
<include name="**/*" />
</fileset>
</copy>
<copy todir="build/src">
<fileset dir="project/java">
<include name="**/*" />
</fileset>
</copy>
<javac fork="true" executable="${java8.jdk.home}\bin\javac.exe" includeantruntime="false" source="1.8" target="1.8" srcdir="build/src" destdir="build/classes" encoding="UTF-8">
<classpath>
<fileset dir="build/libs">
<include name="*" />
</fileset>
<filelist>
<file name="${java8.jdk.home}\jre\lib\ext\jfxrt.jar" />
</filelist>
</classpath>
</javac>
<!-- Copy over none Java-Files -->
<copy todir="build/classes">
<fileset dir="project/resources">
<exclude name="**/*.java" />
</fileset>
<fileset dir="project/java">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="do-deploy" depends="setup-staging-area, do-compile, init-fx-tasks">
<delete file="dist" />
<delete file="deploy" />
<mkdir dir="dist" />
<mkdir dir="dist/libs" />
<copy todir="dist/libs">
<fileset dir="externalLibs">
<include name="*" />
</fileset>
</copy>
<fx:resources id="appRes">
<fx:fileset dir="dist" includes="app.jar" />
<fx:fileset dir="dist" includes="libs/*" />
</fx:resources>
<fx:application id="fxApplication" name="appDesk" version="3.0" mainClass="it.pianetatecno.app.client.Main" preloaderclass="it.pianetatecno.app.client.ui.preloader.SplashScreenUi" toolkit="fx" />
<fx:jar destfile="dist/app.jar">
<fx:application refid="fxApplication" />
<fileset dir="build/classes">
</fileset>
<fx:resources refid="appRes" />
<manifest>
<attribute name="Implementation-Vendor" value="PianetaTecno" />
<attribute name="Implementation-Title" value="app Desk" />
<attribute name="Implementation-Version" value="3.0.0" />
</manifest>
</fx:jar>
<mkdir dir="deploy" />
<!-- Need to use ${basedir} because somehow the ant task is calculating the directory differently -->
<fx:deploy outdir="${basedir}/deploy" outfile="appDesk" nativeBundles="all" height="768" width="1024" verbose="true">
<fx:info title="app Desk" vendor="PianetaTecno" copyright="Copyright PianetaTecno. Tutti i diritti riservati" />
<fx:application refId="fxApplication" />
<fx:resources refid="appRes" />
<fx:preferences shortcut="true" install="true" menu="true" />
<fx:permissions elevated="true" />
<!-- Custom JVM setup for application -->
<fx:platform basedir="${java8.jdk.home}">
<fx:jvmarg value="-Xmx1024m" />
</fx:platform>
</fx:deploy>
</target>
</project>
When I try to run the native bundle on Windows I've this exception:
23/12/2014 10:41:49 DEBUG Main:? - stop()
23/12/2014 10:41:49 INFO ApacheAsyncTransport:54 - Starting Apache HttpAsyncClient transport...
23/12/2014 10:41:49 INFO ApacheAsyncTransport:54 - Apache HttpAsyncClient transport started.
23/12/2014 10:41:49 INFO WebSocketTransport:54 - Starting WebSocket transport...
23/12/2014 10:41:49 INFO WebSocketTransport:54 - WebSocket transport started.
23/12/2014 10:41:49 DEBUG AbstractPagedCollection:90 - create collection
23/12/2014 10:41:50 ERROR Main:? -
java.lang.IllegalStateException: Toolkit has exited
at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:333)
at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:307)
at com.sun.javafx.application.LauncherImpl.notifyCurrentPreloader(LauncherImpl.java:971)
at com.sun.javafx.application.LauncherImpl.notifyPreloader(LauncherImpl.java:983)
at javafx.application.Application.notifyPreloader(Application.java:369)
at it.pianetatecno.app.client.Main$GraniteSpringStartThread.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)