Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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);
}
}
Solved! Go to Solution.
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.
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.
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.
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.
Thank you for your reply. It works fine
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:
Any help of how to assemble the code, creotk.dat, config.pro?
Thanks in advance