2

I have and osgi based application. The loading process is the following: start.sh runs not osgi loader.jar which starts felix and installs and starts bundles. By other words start.sh->loader.jar->osgi+bundles. I want to show loading process in loader.jar via javafx and I use there Application.launch(Gui.class). Everything is ok. The problem appears when in osgi bundle main program is started (also via Application.launch) and I get :

Caused by: java.lang.IllegalStateException: Application launch must not be called more than once

At stackoverflow I found the following solution how to run the second application https://stackoverflow.com/a/13439473/4568213. However, the provided solution works only if it's located "inside" javafx application, for example in start() method. If it's out it throws

Caused by: java.lang.IllegalStateException: Not on FX application thread; currentThread = main" exception.

How can I solve such problem. By other words how to get inside running javafx application and create the second stage?

Community
  • 1
  • 1
  • Use the solution you linked, but wrap the code to start the second app in `Platform.runLater(...)`. – James_D May 26 '15 at 12:28
  • @James_D I tried it. However the code inside Platform.runlater is not called. –  May 26 '15 at 12:30
  • 1
    Try adding a call to `Platform.setImplicitExit(false)` before you show the first window. Otherwise the FX Application Thread will exit when you close that first window. – James_D May 26 '15 at 12:33
  • 1
    @James_D Thank you very much! It works! I do Application.launch(..)+Platform.setImplicitExit(false) in loader and in osgi bundle I do Platform.runLater(new Runnable(){ Override public void run() { Stage stage=new Stage();}}); Is it safe way? –  May 26 '15 at 15:05

0 Answers0