cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

JavaFX in J-link

sjuraj
15-Moonstone

JavaFX in J-link

Hello guys,

I am trying to implement JavaFX in my J-link app. A JavaFX app is run by calling main method of the JFXapp class. When I call main method in start method of J-link app, the java.lang.ClassNotFoundExeption is caught.

Can I somehow solve this problem to implement JavaFX components in my J-link app?

PS: my source code:

--------- J-link app class ----------

import com.ptc.cipjava.jxthrowable;

import com.ptc.pfc.pfcGlobal.pfcGlobal;

import com.ptc.pfc.pfcSession.Session;

public class TestApp {

    public static void start() throws jxthrowable {

      

        Session curSession = pfcGlobal.GetProESession();

        curSession.UIShowMessageDialog("App started !", null);

        String[] args = {};

        JFX.main(args);

    }

  

    public static void stop() {

      

        System.out.println("Stopped");

    }

}

--------- JavaFX app class ----------

import com.ptc.cipjava.jxthrowable;

import com.ptc.pfc.pfcGlobal.pfcGlobal;

import com.ptc.pfc.pfcSession.Session;

import javafx.application.Application;

import javafx.scene.Group;

import javafx.scene.Scene;

import javafx.stage.Stage;

public class JFX extends Application {

  

    public static void main(String[] args) throws jxthrowable {

             

        Session curSession = pfcGlobal.GetProESession();

        curSession.UIShowMessageDialog("Class of JavaFX app found!", null);

      

        try {

            launch(args);

        } catch (Exception e) {

          

            curSession.UIShowMessageDialog(e.getMessage(), null);

        }

    }

  

    @Override

    public void start(Stage primaryStage) throws Exception {

        init(primaryStage);

        primaryStage.show();

      

    }

  

    private void init(Stage primaryStage){

      

        Group root = new Group();

        Scene scene = new Scene(root);

        primaryStage.setTitle("JavaFX-J-link app");

        primaryStage.setScene(scene);

    }

}

ACCEPTED SOLUTION

Accepted Solutions

It is possible to use JavaFX in synchronous JLink applications but you can't use it directly by extending the Application class. What I'm doing to use JavaFX is:

1. Use my own JRE and not the Creo embedded version.

2. In the PSF file I have added "ENV=PRO_JAVA_COMMAND=c:\...\jre\bin\java.exe -Dprism.order=sw -Dprism.vsync=false". The arguments are important otherwise some rendering threads run into an infinite loop and cause a very high CPU load.

3. To get a modal dialog I'm using a good old JDialog with just one JFXPanel. In this JFXPanel I can show the JavaFX controls


So as I said before it is not directly a JavaFX application but for me it was important to have a modal dialog and to use the JavaFX controls.

View solution in original post

6 REPLIES 6
sjuraj
15-Moonstone
(To:sjuraj)

i have solved my problem. There is no possibility to use JavaFX app in synchronous mode because JavaFX create new thread which is not allowed in synchronou j-link app. You can make JavaFX UI application in asynchronous j-link application.

rmcboaty
10-Marble
(To:sjuraj)

how is the async API compared to the sync one (jlink) with regards to speed of execution, do you know perhaps?

i.e. are we talking seconds to perform some easy tasks or tenths of seconds - suppressing a feature for example or something like that.

sjuraj
15-Moonstone
(To:rmcboaty)

In general async app is always slower than sync. You should use async when it is really needed (you need non-modal UI for example). You can even run sync methods from within async application by using task base library.

It is possible to use JavaFX in synchronous JLink applications but you can't use it directly by extending the Application class. What I'm doing to use JavaFX is:

1. Use my own JRE and not the Creo embedded version.

2. In the PSF file I have added "ENV=PRO_JAVA_COMMAND=c:\...\jre\bin\java.exe -Dprism.order=sw -Dprism.vsync=false". The arguments are important otherwise some rendering threads run into an infinite loop and cause a very high CPU load.

3. To get a modal dialog I'm using a good old JDialog with just one JFXPanel. In this JFXPanel I can show the JavaFX controls


So as I said before it is not directly a JavaFX application but for me it was important to have a modal dialog and to use the JavaFX controls.

sjuraj
15-Moonstone
(To:GuentherPrem)

Thank you for your reply. It works fine

T_F
16-Pearl
16-Pearl
(To:sjuraj)

Hello,

 

I've made a few sync app with java. Now I would like to create a few app with java fx. But didn't foud a way to start the application. Every time I run CREO, i've the message error:

 

T_F_0-1580939113930.png

 

Any help of how to assemble the code, creotk.dat, config.pro?

 

Thanks in advance

Announcements


Top Tags