Signing a JavaFX application

Hi!
I have two questions regarding signing of a JavaFX application:
1. In the documentation I read that there is no need to sign an application. But when I try to run a sample application (without any need of special security) in a web browser, I get a runtime error if I don't sign the application before. Is it necessary to sign a JavaFX application if it is intended to run in the browser?
2. I am signing my JavaFX application with the corresponding Ant-Task. So far I created a keystore a self signed certificate and it works.
Is it possible to use a commercial certificate I use for an apache webserver and how? I could not find any information concerning this topic.
Thanks in advance!

990382 wrote:
Hi!
I have two questions regarding signing of a JavaFX application:
1. In the documentation I read that there is no need to sign an application. But when I try to run a sample application (without any need of special security) in a web browser, I get a runtime error if I don't sign the application before. Is it necessary to sign a JavaFX application if it is intended to run in the browser?It depends on what your application is doing, but in the majority of cases the answer is "yes". Certain actions are prohibited for embedded applications unless they specifically request permissions for them, and to do so the application needs to be signed. Examples of these actions are reading and writing to the file system, or some actions with multithreading. Another important example is suppressing access checks in order to manipulate inaccessible (usually private) fields or invoke inaccessible methods by reflection. Injection of FXML-defined objects into a controller relies on being able to do this. So in short, an application that uses FXML will almost always need to be signed.
2. I am signing my JavaFX application with the corresponding Ant-Task. So far I created a keystore a self signed certificate and it works.
Is it possible to use a commercial certificate I use for an apache webserver and how? I could not find any information concerning this topic.
Thanks in advance!You need to import the commercial certificate into the keystore. I've never needed to do this (at least, not yet), but there is some documentation on how to do so [url http://docs.oracle.com/javase/tutorial/security/toolsign/signer.html]here. The optional step (between steps 3 and 4) is the one of interest to you.

Similar Messages

  • How to run a JavaFX application like a native executable?

    Hi,
    How can a user run my JavaFX application on Windows without having to install JavaFX SDK or using any web related method? I want to give the impression that my JavaFX application is native.
    What should be bundled together for a complete JavaFX runtime environment?
    Thanks in advance
    Argon

    - I've installed javafx SDK on my machine
    - I created a new java application
    - I added all jar my java app in this dir. (javafx\javafx-sdk\lib\desktop)
    Java app:
    public static void main(String[] args) {
    Context context = FXLocal.getContext();
    FXClassType instance = context.findClass("mainClassName.Main");
    FXLocal.ObjectValue obj = (ObjectValue)instance.newInstance();
    JavaInterface ji = (JavaInterface)obj.asObject();
    ji.runFX();
    and i get this error
    Exception in thread "main" java.lang.SecurityException: class "javafx.util.Math"'s signer information does not match signer information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(ClassLoader.java:776)
    at java.lang.ClassLoader.preDefineClass(ClassLoader.java:488)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at com.sun.javafx.scene.layout.region.BackgroundFill$BackgroundFillsType.convert(Unknown Source)
    at com.sun.stylesheet.StyleHelper.lookup(Unknown Source)
    at com.sun.stylesheet.StyleHelper.transitionToState(Unknown Source)
    at javafx.scene.Node.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.Parent.impl_processCSS(Unknown Source)
    at javafx.scene.Scene.doCSSPass(Unknown Source)
    at javafx.scene.Scene.userInit$(Unknown Source)
    at com.sun.javafx.runtime.FXBase.complete$(Unknown Source)
    at mainClassName.Main$1Local$1.doit$$0(Main.fx:164)
    at mainClassName.Main.runFX(Main.fx:153)
    at javafxjava.Main.main(Main.java:30)
    i had use it :
    jarsigner -keystore keystore-name -storepass keystore-password
    -keypass key-password jar-file alias-name
    but same error occurred.
    Thanks.

  • How can I invoke JavaFX application in Java project

    I want to set an actionlistener on a button.When I click the button,it will run the JavaFX application.
    Any idea?Thanks in advance.

    A program that launches JavaFX programs? Something like this might work:
         * Launches the given JNLP file.
         * @param jnlpFileURL The url to the JNLP file of the JavaFX application we are launching.
        public void launchFXApplication(String jnlpFileURL) throws Exception {
            //Retrieve the runtime.
            Runtime runtime = Runtime.getRuntime();
            //Create the commands we will be executing.
            String[] commands = new String[] {
                System.getProperty("java.home") + File.separator + "bin" + File.separator + "javaws",
                jnlpFileURL
            //Execute it.
            final Process process = runtime.exec(commands);
            //Need to read the input.
            final BufferedReader errorReader = new BufferedReader(
                new InputStreamReader(process.getErrorStream()));
            final BufferedReader outputReader = new BufferedReader(
                new InputStreamReader(process.getInputStream()));
            //Input MUST be read and should be done in separate threads.
            Thread errorThread = new Thread(new Runnable() {
                public void run() {
                    String line;
                    try {
                        while ((line = errorReader.readLine()) != null) {
                            //Examine it if you like. Optional.
                        errorReader.close();
                    } catch (IOException ex) {
                        ex.printStackTrace();
            Thread outputThread = new Thread(new Runnable() {
                public void run() {
                    String line;
                    try {
                        while ((line = outputReader.readLine()) != null) {
                            //Doing something with the input is optional.
                        errorReader.close();
                    } catch (IOException ex) {
                        ex.printStackTrace();
            //Run the separate threads.
            errorThread.start();
            outputThread.start();
            //Wait until it's done.
            process.waitFor();
        }This code will of course need to be signed if you intend to launch it as an applet or via webstart.
    Edited by: aidreamer on Aug 14, 2011 8:35 PM

  • Problem running JavaFX application as web applet / web start

    Hi All,
    I need to run a JavaFX application as applet in a web page. To do that I use the html page
    generated by javafxpackager and all works fine if I launch the html page locally from my
    pc but when I load the html page from web server the application runs slow till freezing the browser.
    All jars are signed with a self-signed certificate, I've tried with Firefox, Chrome, IE and different servers.
    Same problem with web start (jnlp), locally works fine, launched from web it freezes.
    Enabling Java Console I've noticed a lot of log like:
    basic: JNLP2ClassLoader.findClass: java.lang.ImageView: try again ..
    basic: JNLP2ClassLoader.findClass: java.lang.ImageView: try again ..
    basic: JNLP2ClassLoader.findClass: java.lang.Image: try again ..
    basic: JNLP2ClassLoader.findClass: java.lang.Image: try again ..
    network: Cache entry not found [url: http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory, version: null]
    network: Connecting http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory with proxy=DIRECT
    network: Connecting http://www.mysite.com:80/ with proxy=DIRECT
    network: Connecting http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory with cookie "has_js=1"
    basic: JNLP2ClassLoader.findClass: java.lang.Font: try again ..
    basic: JNLP2ClassLoader.findClass: java.lang.Font: try again ..
    basic: JNLP2ClassLoader.findClass: javafx.scene.control.Font: try again ..
    basic: JNLP2ClassLoader.findClass: javafx.scene.control.Font: try again ..
    basic: JNLP2ClassLoader.findClass: javafx.scene.layout.Font: try again ..
    basic: JNLP2ClassLoader.findClass: javafx.scene.layout.Font: try again ..
    network: Cache entry not found [url: http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory, version: null]
    network: Connecting http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory with proxy=DIRECT
    network: Connecting http://www.mysite.com:80/ with proxy=DIRECT
    network: Connecting http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory with cookie "has_js=1"
    What am I doing wrong?
    This is my jnlp (MyApp.jnlp)
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec = "1.0" xmlns:jfx = "http://javafx.com" codebase = "http://www.mysite.com/applet/" href = "MyApp.jnlp">
    <information>
    <title>MyApp</title>
    <vendor>MyApp</vendor>
    <description>Sample JavaFX 2.0 application.</description>
    <homepage href = "http://www.mysite.com/applet/"/>
    <offline-allowed/>
    </information>
    <resources>
    <jfx:javafx-runtime version = "2.2+" href = "http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
    </resources>
    <resources>
    <j2se version = "1.6+" href = "http://java.sun.com/products/autodl/j2se"/>
    <jar href = "MyApp.jar" size = "2836601" download = "eager"/>
    <jar href = "libs/gson-2.2.2.jar" size = "189285" download = "eager"/>
    <jar href = "libs/sun.jar" size = "83743" download = "eager"/>
    </resources>
    <applet-desc width = "1280" height = "1024" main-class = "com.javafx.main.NoJavaFXFallback" name = "MyApp">
    <param name = "requiredFXVersion" value = "2.2+"/>
    </applet-desc>
    <jfx:javafx-desc width = "1280" height = "1024" main-class = "test.App" name = "MyApp"/>
    <update check = "background"/>
    </jnlp>
    and this my html page
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>My App</title>
    <script src="http://java.com/js/dtjava.js"></script>
    <script>
    function launchApplication(jnlpfile) {
    dtjava.launch( {
    url : 'MyApp.jnlp'
    javafx : '2.2+'
    return false;
    </script>
    <script>
    function javafxEmbed_fxApplication() {
    dtjava.embed(
    id : 'fxApplication',
    url : 'MyApp.jnlp',
    placeholder : 'MyAppId',
    width : 1280,
    height : 1024
    javafx : '2.2+'
    <!-- Embed FX application into web page once page is loaded -->
    dtjava.addOnloadCallback(javafxEmbed_fxApplication);
    </script>
    </head>
    <body>
              <div id="MyAppId"></div>
    </body>
    </html>
    Thank you

    Some more info,
    I watched the web server logs and I found many repeated log entries like
    "GET /applet/myapplet.html/META-INF/services/javax.xml.stream.XMLInputFactory HTTP/1.1" 404 19023 "-" "Mozilla/4.0 (Windows 7 6.1) Java/1.7.0_09"
    Googling this I've found many posts regarding similar problems:
    http://stackoverflow.com/questions/7997566/web-service-client-applet-keeps-asking-for-meta-inf-services-javax-xml-ws-sp
    http://stackoverflow.com/questions/2340969/applet-served-by-java-web-start-resources-requested-to-web-server-before-look-i
    It seems to be a strange Behaviour of the JNLPClassLoader that tries to load classes from server instead from jar or local class path.
    Somebody suggests to remove all logging entries from code or to add "codebase_lookup = false" to applet parameters but this does not solve the problem.
    I use FXML to define my UI and I think that every time an fxml is loaded JNLPClassLoader tries to load the xml parser (javax.xml.stream.XMLInputFactory)
    from server.
    Somebody have any idea?
    Thank you.

  • "java.util.PropertyPermission user.language write" in my javafx application

    Hello Everybody.
    I developed javafx application that has to run in web application under apache tomcat server.
    There is a line of code that changes the Locale ( Locale.setDefault(new Locale("iw", "IL")); ).
    When running this application in stand-alone it works fine, but when i try to run it from browser, it throws excaption "java.security.AccessControlException: access denied (java.util.PropertyPermission user.language write)"
    I know that javafx (when it is running in browser) is no more then applet, and it is necessary to grant the access to user.language property in "something.policy" file. But it is only theory for me, and in practice i don't know how to do this.
    Thank you.
    Igor.

    Adding this to your jnlp file should also work:
         <security>
         <all-permissions/>
         </security>
    Doing so should work for any user that accesses your application from the web. Sign the jar first though (use the NetBeans sign option when generating your webstart application).
    Here is a [great JNLP|http://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html] reference that shows the other options.

  • How to display the javafx application to a web application

    I've got a javaFX application .(My IDE is NetBeans 6.8)I choose the main.fx in the opened project,then run>>project configure >> web browser and Shift+F6.It runs as expected.
    and the path is "+http://localhost:8082/servlet/org.netbeans.modules.javafx.project.JnlpDownloadServlet/E%3A/Source+Codes/NTBS/MyProject/dist//MyPage.html+"
    However,I tried to access that page again when I closed the NetBeans.It failed.
    so I attempt to change the default html code.
    default code
    <script src="http://dl.javafx.com/1.2/dtfx.js"></script>
    <script>
        javafx(
                  archive: "MyJar.jar",
              draggable: true,
                  width: 300,
                  height: 300,
                  code: "MyPackage.Main",
                  name:
    "MyProject"
    </script>the changed code
    <script src="http://dl.javafx.com/1.2/dtfx.js"></script>
    <script>
        javafx(
            archive: "MyJar.jnlp",//or the like this   archive: "MyJar_browser.jnlp",
              draggable: true,
                  width: 300,
                  height: 300,
                  code: "MyPackage.Main",
                  name:
    "MyProject"
    </script>but it is futile.
    Considering maybe it needs server, I put the jar file and html file into tomcat ,it is nouse either.

    Thank you!
    yes I do.but I tried many many times.Finally,I got a phenomenon .Under Apache Tomcat container ,we can not access them by jnlp files,while the javafx's jar files set into the WEB-INF folder.
    Surely.we must put new another foler on the root to place javafx.
    Actually,we habitually put jar files into the lib folder which just under WEB-INF foler,and the JSP&servlet's specification.
    Is there a new way?

  • JavaFX application is cached on client machine

    Hi,
    I have a developed a browser embedded JavaFx application and deployed on a production machine. When I deploy a newer version of .jar file on production machine it is not updated on all client machines because the .jar file is cached. The only way the end user can get latest version of my javafx application is by clearing cache files from java control panel.
    Is there a way I can force my application to always download the latest version of jar file from server?
    Thanks,
    Sridhar

    I have updated the java version on some of the boxes I've tested. I am now noticing that on some PC browsers with IE, the tabbing will only tab them through the browser and not the javafx application.
    I am going to have to deploy as a webstart application for now.
    I will have to work out the kinks later.

  • How can I implement a comfirmation window when closing javafx application?

    hi,guys
    I'd like to add a confirmation window when user is closing my javafx application,if user click yes, I will close the application,if no ,I wouldn't close it ,how can I implement this function?
    primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>(){
                   @Override
                   public void handle(WindowEvent arg0) {
                        try
                             //todo
                        catch(Exception ex)
                             System.out.print(ex.getMessage()+"\r\n");
            });

    Hi. Here is an example:
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Pos;
    import javafx.stage.*;
    import javafx.scene.*;
    import javafx.scene.paint.Color;
    import javafx.scene.layout.*;
    import javafx.scene.control.*;
    public class ModalDialog {
        public ModalDialog(final Stage stg) {
         final Stage stage = new Stage();          
            //Initialize the Stage with type of modal
            stage.initModality(Modality.APPLICATION_MODAL);
            //Set the owner of the Stage
            stage.initOwner(stg);
            Group group =  new Group();
            HBox hb = new HBox();
             hb.setSpacing(20);
            hb.setAlignment(Pos.CENTER);
            Label label = new Label("You are about to close \n your application: ");
            Button no  = new Button("No");
            no.setOnAction(new EventHandler<ActionEvent>() {
                public void handle(ActionEvent event) {
                       stage.hide();
            Button yes  = new Button("Yes");
            yes.setOnAction(new EventHandler<ActionEvent>() {
                public void handle(ActionEvent event) {
                       stg.close();
             hb.getChildren().addAll(yes, no);
             VBox vb =  new VBox();
             vb.setSpacing(20);
             vb.setAlignment(Pos.CENTER);
             vb.getChildren().addAll(label,hb);
            stage.setTitle("Closing ...");
            stage.setScene(new Scene( vb, 260, 110, Color.LIGHTCYAN));       
            stage.show();
    }Test:
       import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import javafx.stage.*;
    * @author Shakir
    public class ModalTest extends Application {
         * @param args the command line arguments
        public static void main(String[] args) {
            Application.launch(ModalTest.class, args);
        @Override
        public void start(final Stage primaryStage) {
            primaryStage.setTitle("Hello World");
            Group root = new Group();
            Scene scene = new Scene(root, 300, 250, Color.LIGHTGREEN);
           primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>(){
                   @Override
                   public void handle(WindowEvent arg0) {
                                    arg0.consume();
                        try
                         ModalDialog md = new ModalDialog(primaryStage);
                        catch(Exception ex)
                             System.out.print(ex.getMessage()+"\r\n");
            primaryStage.setScene(scene);
            primaryStage.show();
    }

  • CSS Error in running javafx application after move to use jdk8

    Hi all,
    I'm running an javafx app fine with build: jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012 which uses jdk7 perfectly fine on the raspberry pi (which i also keep as backup until newer builds well, are starting to work with my app).
    I'm getting an exception related to CSS (seems to me) when i try to run my javafx app (as well through netbeans on windows xp as through command line on the raspberry pi):
    I've try'd two netbeans versions, the stable 7.3 with jdk 1.8 build 100 and nightly 7.4 with the same jdk 1.8 build. Building goes fine on both these versions.
    The exception is:
    Exception in thread "JavaFX Application Thread"
       java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at java.util.ArrayList.rangeCheck(ArrayList.java:638)
       at java.util.ArrayList.get(ArrayList.java:414)
       at com.sun.javafx.css.StyleMap.getCascadingStyles(StyleMap.java:121)
       at javafx.scene.CssStyleHelper.getStyle(CssStyleHelper.java:683)
       at javafx.scene.CssStyleHelper.lookupFont(CssStyleHelper.java:1548)
       at javafx.scene.CssStyleHelper.transitionToState(CssStyleHelper.java:460)
       at javafx.scene.Node.impl_processCSS(Node.java:8665)
       at javafx.scene.Parent.impl_processCSS(Parent.java:1192)
       at javafx.scene.Parent.impl_processCSS(Parent.java:1204)
       at javafx.scene.Node.processCSS(Node.java:8575)
       at javafx.scene.Scene.doCSSPass(Scene.java:538)
       at javafx.scene.Scene.preferredSize(Scene.java:1503)
       at javafx.scene.Scene.impl_preferredSize(Scene.java:1570)
       at javafx.stage.Window$9.invalidated(Window.java:733)
       at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109)
       at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:143)
       at javafx.stage.Window.setShowing(Window.java:799)
       at javafx.stage.Window.show(Window.java:814)
       at javafx.stage.Stage.show(Stage.java:243)
       at pidome.client.PidomeClient$1$1.run(Unknown Source)
       at com.sun.javafx.application.PlatformImpl$5$1.run(PlatformImpl.java:244)
       at com.sun.javafx.application.PlatformImpl$5$1.run(PlatformImpl.java:241)
       at java.security.AccessController.doPrivileged(Native Method)
       at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:241)
       at com.sun.glass.ui.lens.LensApplication$RunnableEvent.dispatch(LensApplication.java:169)
       at com.sun.glass.ui.lens.LensApplication._runLoop(LensApplication.java:756)
       at com.sun.glass.ui.lens.LensApplication.access$700(LensApplication.java:55)
       at com.sun.glass.ui.lens.LensApplication$4.run(LensApplication.java:815)
       at java.lang.Thread.run(Thread.java:724)
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at java.util.ArrayList.rangeCheck(ArrayList.java:638)
       at java.util.ArrayList.get(ArrayList.java:414)
       at com.sun.javafx.css.StyleMap.getCascadingStyles(StyleMap.java:121)
       at javafx.scene.CssStyleHelper.getStyle(CssStyleHelper.java:683)
       at javafx.scene.CssStyleHelper.lookupFont(CssStyleHelper.java:1548)
       at javafx.scene.CssStyleHelper.transitionToState(CssStyleHelper.java:460)
       at javafx.scene.Node.impl_processCSS(Node.java:8665)
       at javafx.scene.Parent.impl_processCSS(Parent.java:1192)
       at javafx.scene.Parent.impl_processCSS(Parent.java:1204)
       at javafx.scene.Node.processCSS(Node.java:8575)
       at javafx.scene.Node.processCSS(Node.java:8566)
       at javafx.scene.Scene.doCSSPass(Scene.java:538)
       at javafx.scene.Scene.access$3600(Scene.java:189)
       at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2294)
       at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:325)
       at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:533)
       at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:513)
       at com.sun.javafx.tk.quantum.QuantumToolkit$16.run(QuantumToolkit.java:380)
       at com.sun.glass.ui.lens.LensApplication$RunnableEvent.dispatch(LensApplication.java:169)
       at com.sun.glass.ui.lens.LensApplication._runLoop(LensApplication.java:756)
       at com.sun.glass.ui.lens.LensApplication.access$700(LensApplication.java:55)
       at com.sun.glass.ui.lens.LensApplication$4.run(LensApplication.java:815)
       at java.lang.Thread.run(Thread.java:724)
    On line 22 is where i think my problem really begins. This line correspondents to my code on line 14:
        @Override
        public void start(Stage primaryStage) {
            redirectOutputToLog();
            rootStage = primaryStage;
            rootStage.setTitle("PiDome Client");
            rootStage.setFullScreen(true);
            rootStage.initStyle(StageStyle.UNDECORATED);
            ready.addListener(new ChangeListener<Boolean>(){
                @Override
                public void changed(
                    ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                        if (Boolean.TRUE.equals(t1)) {
                            rootStage.setScene(mainStage.scene());
                            rootStage.show();
            initialize();
    The rest of my main file is as follows (snippet):
    public class PidomeClient extends Application implements NetworkingEventListener,ClientDataConnectionListener,DomoticsEventListener,MainSceneEventListener,PreloaderCredentials {
    MainScene mainStage;
    BooleanProperty ready = new SimpleBooleanProperty(false);
      public void start(Stage primaryStage){
      /* See above snippet */
        public final void initialize(){
            /* code */
            mainStage = new MainScene();
            /* code */
      /* some functions for the listeners added */
        @Override
        public void handleMainSceneEvent(MainSceneEvent event) {
            if(event.getEventType().equals(MainSceneEvent.SCENEBUILDDONE)){
                notifyPreloader(new StateChangeNotification(StateChangeNotification.Type.BEFORE_START));
                ready.setValue(Boolean.TRUE);
    Some code from my MainScene class:
    public final class MainScene {
        Pane root = new Pane();
        Scene appScene = new Scene(root, DisplayConfig.getScreenWidth(), DisplayConfig.getScreenHeight());
        String theme = Theme.getCurrent();
        NotificationBar notBar = new NotificationBar();
        TopBar topBar          = new TopBar();
        MainControl mainControl= new MainControl();
        BottomBar bottomBar    = new BottomBar();
        //Console   console      = new Console();
        SubControl subControl     = new SubControl();  
      public MainScene(){
        public final void createScene(){
            LOG.debug("Screen dimensions: width: {}, height: {}",DisplayConfig.getScreenWidth(), DisplayConfig.getScreenHeight());
            root.getStylesheets().add(theme + "main.css");
            root.getChildren().add(notBar);
            root.getChildren().add(topBar);
            root.getChildren().add(mainControl);
            root.getChildren().add(bottomBar);
            root.getChildren().add(subControl);
            //console.show();
            _fireSceneBuildDone();
        public final Scene scene(){
            return appScene;
        public final void stop(){
            //topBar.stopThreads();
        public synchronized static void addDoneListener(MainSceneEventListener l){
            _listeners.add(l);
        final synchronized void _fireSceneBuildDone(){
            LOG.debug("New event: {}", MainSceneEvent.SCENEBUILDDONE);
            MainSceneEvent serviceEvent = new MainSceneEvent(this, MainSceneEvent.SCENEBUILDDONE);
            Iterator listeners = _listeners.iterator();
            while (listeners.hasNext()) {
                ((MainSceneEventListener) listeners.next()).handleMainSceneEvent(serviceEvent);
    Further explanation:
    The lines 8 until 14 are the children that have they're own CSS files which are included, they do not contain the .root element. This element is only present in the main.css class. As you can see i'm using a preloader which also has it's own CSS but with the .root element, but this one does not contain anything related to fonts. I have try'd a lot of things because i'm thinking i'm in error because i have seen this on the javafx 8 Performance ideas page (https://wiki.openjdk.java.net/display/OpenJFX/Performance+Ideas): "Rather than running CSS at start up, precompute the defaults and initialize FX to have these values.  This should improve start up time." I do not know if this is related. What i've tryed is
    - move the children created in MainScene to another location,
    - Completely discard the preloader (as wel as in netbeans is in the code),
    - Removed everything that was font related out of my css,
    - Removed everything that was font related from my code,
    - Removed the traling slash to the path to the css returned by my function theme.getCurrent(); But then i get the error that the file is not found.
    - Went completely procedural when creating the scene objects and children.
    I posted a recent amount of  code, and, i'm out of options at the moment. So, is there a bug or am i doing something wrong and should i rethink on how CSS is handled in FX 8?
    Best regards,
    John
    Some changes in explanation.
    Message was edited by: JohnMefster

    Well, i found the/a solution for the above:
    I've put all my css in one file, and found some empty declarations like #mainbottomcontainer .content .label { }. I removed these 3 empty declarations and now my app also works in build 101. So i do now think this has to do with the CSS remark posted above. And i do think this is due to setting CSS in the declaration part of a class at startup (like in my MainScene class above), but i'm not sure. But, it is fixed for now.
    John.

  • Getting GTK error while running javaFX application on linux

    I developed an JavaFX application that works fine on Windows. So, I tried to run this same application on Linux (ubuntu x86) and it is not working. I setup all the environment with following this article : http://docs.oracle.com/javafx/2.0/release_notes_linux/jfxpub-release_notes_linux.htm. The Sample JavaFX applications available at http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html work great on Linux. But when I run my application, I got this error:
    java -jar prototipoGui.jar
    Exception in thread "main" java.lang.RuntimeException: Application launch error
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:122)
    at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.gtk.GtkApplication._invokeLater(Ljava/lang/Runnable;)V
    at com.sun.glass.ui.gtk.GtkApplication._invokeLater(Native Method)
    at com.sun.glass.ui.Application.invokeLater(Application.java:336)
    at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:617)
    at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:138)
    at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:171)
    at com.sun.javafx.application.PlatformImpl.tkExit(PlatformImpl.java:264)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:417)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    ... 1 more

    I get the same message, when running my application in stand alone.
    May be there is a problem when running in aa KDE environment.
    But I developed my app in Eclipse under KDE4. If the app is started by IDE it runs.

  • FileLock is not working in Mac OS  - Used in Javafx application

    In my application, there is pause & resume functionality on the file download.
    To achieve this, we used java.nio.channels.FileLock to lock the file.
    It is working fine in Windows, not in Macintosh OS 10.8.
    We are using JRE 1.7 u 15 to run the application.
    Here is the code I am using to lock a file which is working fine in Windows, but not in Macintosh
    FileOutputStream file = null;
    FileChannel dbFc = null;
    FileLock dbFl = null;
    file = new FileOutputStream( new File(sFilePath));
    dbFc = file.getChannel();
    dbFl = dbFc.lock();
    file.write(buffer,0,read);
    When I am applying lock on the FileChannel, it is not able to lock on Mac OS systems.
    Is there any alternate I can use instead of FileLock .
    All this logic is part of JavaFx application which will run from user's machine
    Please suggest

    Not really a JavaFX question, but a quick google search indicates that on some Apple OS version, lock is not supported.

  • How to convert my JavaFX application into a service

    Dear Folks,
    I have developed an JavaFX application to view images with functionalities to apply various effects to images, play as slide show..etc
    I would like to make this as an service so that, a third party can make use of the service, add to his mashup and run this application in their mashup.
    How do I achieve this?

    Tell them to include the browser's JNLP on their server and the related JavaScript code to their page?

  • How to pass Objects from Java App to JavaFX Application

    Hello,
    New to the JavaFX. I have a Java Swing Application. I am trying to use the TreeViewer in JavaFX since it seems to be a bit better to use and less confusing.
    Any help is appreciated.
    Thanks
    I have my Java app calling my treeviewer JavaFX as
    -- Java Application --
    public class EPMFrame extends JFrame {
    Customer _custObj
    private void categoryAction(ActionEvent e)   // method called by Toolbar
            ocsCategoryViewer ocsFX;    //javaFX treeviewer
            ocsFX = new ocsCategoryViewer();    // need to pass in the Customer Object to this Not seeing how to do it.
                                                  // tried ocsFX = new ocsCategoryViewer(_custObj) ;    nothing happened even when set this as a string with a value
    public class ocsCategoryViewer extends Application {
    String _customer;
    @Override
        public void start(Stage primaryStage) {
         TreeView <String> ocsTree;
         TreeItem <String> root , subcat;
      TreeItem <String> root = new TreeItem <String> ("/");
            root.setExpanded(true);
             ocsTree = new TreeView <String> (root);
             buildTree();     // this uses the Customer Object.
            StackPane stkp_root = new StackPane();
            stkp_root.getChildren().add(btn);
            stkp_root.getChildren().add(ocsTree);
            Scene scene = new Scene(stkp_root, 300, 250);
            primaryStage.setTitle("Tree Category Viewer");
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            _customer = args[0];      // temporarily trying to pass in string.
            launch(args);

    JavaFX and Swing integration is documented by Oracle - make sure you understand that before doing further development.
    What are you really trying to do?  The answer to your question depends on the approach you are taking (which I can't really work out from your question).  You will be doing one of:
    1. Run your Swing application and your JavaFX application as different processes and communicate between them.
    This is the case if you have both a Swing application with a main which you launch (e.g. java MySwingApp) and JavaFX application which extends application which you launch independently (e.g. java MyJavaFXApp).
    You will need to do something like open a client/server network socket between the applications and send the data between them.
    2. Run a Swing application with embedded JavaFX components.
    So you just run java MySwingApp.
    You use a JFXPanel, which is "a component to embed JavaFX content into Swing applications."
    3. Run a Java application with embedded Swing components.
    So you just run java MyJavaFXApp.
    You use a SwingNode, which is "used to embed a Swing content into a JavaFX application".
    My recommendation is:
    a. Don't use approach number one and have separate apps written in Swing and Java - that would be pretty complicated and unwarranted for almost all applications.
    b. Don't mix the two toolkits unless you really need to.  An example of a real need is that you have a huge swing app based upon the NetBeans platform and you want to embed a couple of JavaFX graphs in there.  But if your application is only pretty small (e.g., it took less than a month to write), just choose one toolkit or the other and implement your application entirely in that toolkit.  If your entire application is in Swing and you are just using JavaFX because you think its TreeView is easier to program, don't do that; either learn how to use Swing's tree control and use that or rewrite your entire application in JavaFX.  Reasons for my suggestion are listed here: JavaFX Tip 9: Do Not Mix Swing / JavaFX
    c. If you do need to mix the two toolkits, the answer of which approach to use will be obvious.  If you have a huge Swing app and want to embed one or two JavaFX components in it, then use JFXPanel.  If you have a huge JavaFX app and want to embed one or two Swing components in it, use a SwingNode.  Once you do start mixing the two toolkits be very careful about thread processing, which you are almost certain screw up at least during development, no matter how an experienced a developer you are.  Also sharing the data between the Swing and JavaFX components will be trivial as you are now running everything in the same application within the virtual machine and it is all just Java so you can just pass data around as parameters to constructors and method calls, the same way you usually do in a Java program, you can even use static classes and data references to share data but usually a dependency injection framework is better if you are going to do that - personally I'd just stick to simply passing data through method calls.

  • Digitally Signing Flex/AIR Application

    I am looking for some help with updating an AIR application with a renewed certificate.
    The way that Adobe AIR handles digitally signed certificates is fairly confusing. I think it has changed with the release of AIR 1.5.3 and this change has caught us off guard and has resulted in some problems.
    According to the Adobe website: Prior to AIR 1.5.3, signing an AIR application with a renewed certificate did not always require a migration signature. Starting with AIR 1.5.3, a migration signature is always required for renewed certificates.
    Furthermore: The certificate must be changed before the original certificate expires. If you do not create an update signed with a migration signature before your certificate expires, users will have to uninstall their existing version of your application before installing a new version. As of AIR 1.5.3, an expired certificate can be used to apply a migration signature within a 180 day grace period after the certificate has expired. (You cannot use the expired certificate to apply the main application signature.).
    See:
    http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7ff0. html#WS5b3ccc516d4fbf351e63e3d118666ade46-7cca
    http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS13ACB483-1711-43c0-9049-0A7251630A7D.htm l
    BOTTOM LINE:
    We did not create a "migration signature" within the 180 grace period because we had no updates (bug fixes or enhancements) to our application during this time. When I finally did prepare a new release of our application and signed it with our new certificate, the Adobe installer is not recognizing the new application as an UPDATE of the old application so when you try to install it, the user gets an error message that an application that the same name is already installed. In the past, the installer recognizes the new application as an update and it replaces the old app. I think there may be a way for me to handle this properly, but all of my attempts so far have not produced the results I am looking for.
    The issues may be related to specifying a Publisher ID. We may need to specify the publisherId in the descriptor.xml file, which we have never had to do in the past. However, the publisherId property may only be available in 1.5.3. I have been having trouble specifying the 1.5.3 name space (<application xmlns="http://ns.adobe.com/air/application/1.5.3">). I think that must only be available for newer versions of the compiler. I am currently using 3.5.
    Are there any experts on this topic that can explain How I can package my updated app so that the installer recognizes it as an UPDATE and not a NEW APP with the same name (which doesn't work)?

    Any ideas on this?

  • Exception ... MyClass is not a subclass of javafx.application.Application

    Hi,
    I am creating a Java based Framework, with it proper components that i create based on Java FX, so I know that every Class that uses JavaFx should extends "Application", the problem is that this class already extends from another one to verify the Class Diagram consistency "public class ZCPageDesktop extends ZCAbstractPage", now ZCPageDesktop should also extends "Application" to meet with Java FX specification but Multiple extends are not permitted in Java, So what i did is that i Created a Class Member called "private ZCFXApplication fxapp" which is an instance of the class ZCFXApplication that i created and extends "Application", so i redefined the method public void start(Stage primaryStage){/} then i created also another method to simulate the method public static void draw(String []args){  launch(args) // calling launch } all of this is done in my framework implementation, but when i go to the test , called "UserView" in the main i got this message " Exception in thread "main" java.lang.RuntimeException: Error: class org.zerocouplage.component.test.view.UserView is not a subclass of javafx.application.Application
         at javafx.application.Application.launch(Application.java:211)
         at org.zerocouplage.component.test.view.UserView.main(UserView.java:57)"
    How do i can fix this problem in a way that ZCPageDesktop extends Application, all in respecting the Java FX specification and the non permitted multiple extends ?
    // Test Class
    package org.zerocouplage.component.test.view;
    import static org.zerocouplage.component.common.ZCComponentFactory.newComponent;
    import java.io.IOException;
    import org.zerocouplage.component.api.component.ZCButton;
    import org.zerocouplage.component.api.component.ZCCheckBox;
    import org.zerocouplage.component.api.component.ZCLabel;
    import org.zerocouplage.component.api.component.ZCTextField;
    import org.zerocouplage.component.api.layout.ZCBorderLayout;
    import org.zerocouplage.component.api.page.ZCPage;
    import org.zerocouplage.component.common.exception.ZCCompNotFoundException;
    import org.zerocouplage.component.impl.component.ZCAbstractLabel;
    import com.zerocouplage.api.controller.IZCManager;
    import com.zerocouplage.common.exceptions.ZCExceptionConfig;
    import com.zerocouplage.impl.controller.ZCManagerFactory;
    import org.zerocouplage.component.desktop.page.ZCFXApplication;
    *public class UserView {*
    *     @SuppressWarnings("unused")*
    *     private IZCManager manager;*
    *     public UserView() {*
    *          manager = ZCManagerFactory.getNewManager(this);*
    *     public Object createGui() throws IOException, ZCCompNotFoundException, ZCExceptionConfig {*
    *          ZCPage page = (ZCPage) newComponent(ZCPage.class);*
    *          page.setTitle("Page login");*
    *          ZCBorderLayout layout = (ZCBorderLayout) newComponent(ZCBorderLayout.class);*
    *          ZCAbstractLabel label = (ZCAbstractLabel) newComponent(ZCLabel.class);*
    *          label.setLabel("Nom");*
    *          ZCTextField textField = (ZCTextField) newComponent(ZCTextField.class);*
    *          textField.setText("Text");*
    *          ZCButton button = (ZCButton) newComponent(ZCButton.class);*
    *          button.setText("OK");*
    *          layout.setComponentCenter(button);*
    *          page.setBody(layout);*
    *          return page.display();*
    *     @SuppressWarnings("static-access")*
    *     public static void main(String[] args) {*
    *          UserView userView = new UserView();*
    *          ZCFXApplication Fpage;*
    *          try {*
    *               Fpage=(ZCFXApplication)userView.createGui();*
    *               Fpage.launch(args);*
    *          } catch (IOException | ZCCompNotFoundException | ZCExceptionConfig e) {*
    *               // TODO Auto-generated catch block*
    *               e.printStackTrace();*
    // the implementation of my API the class defining the consistency of the class diagram
    package org.zerocouplage.component.desktop.page;
    import org.zerocouplage.component.impl.page.ZCAbstractPage;
    public class ZCPageDesktop extends ZCAbstractPage {
         * @author Taoufik RIFAI
         private ZCFXApplication fxapp;
         public ZCPageDesktop() throws Exception {
              this.setFxapp(new ZCFXApplication());
         public Object display() {
              fxapp.setTitle(this.getTitle());
              fxapp.setLayout(this.getBody().display());
              return fxapp;
              // seul difference c'est que il faut que dans le test faire
              // f.launch(String[] args) dans le main
         public ZCFXApplication getFxapp() {
              return fxapp;
         public void setFxapp(ZCFXApplication fxapp) {
              this.fxapp = fxapp;
    // the class which extends Application defining the JavaFX specification
    package org.zerocouplage.component.desktop.page;
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    *public class ZCFXApplication extends Application {*
    *     * @author Taoufik RIFAI*
    *     private String title;*
    *     private Object layout;*
    *     public void start(Stage stage) throws Exception {*
    *          Group group = new Group();*
    *          group.getChildren().add((Node) getLayout());*
    *          System.out.println(getTitle());*
    *          if(getTitle()!=null){*
    *               stage.setTitle(getTitle());*
    *          stage.setScene(new Scene(group, 300, 250));*
    *          stage.show();*
    *     public static void draw(String[] argument) {*
    *          launch(argument);*
    *     public Object getLayout() {*
    *          return layout;*
    *     public void setLayout(Object layout) {*
    *          this.layout = layout;*
    *     public String getTitle() {*
    *          return title;*
    *     public void setTitle(String title) {*
    *          this.title = title;*
    *}*

    I guess you are in the wrong forum. Try JavaFX 2.0 and Later
    Timo

Maybe you are looking for