Hello, I am writing an application in java . I use JavaFX as a GUI (I’ll say right away that when using swt there is no such problem).
So, there is a certain function, the duration of which is at least 30 seconds on my laptop. It is quite complex data processing.
When you call it, literally after 1-2 seconds, a window appears that "The Java (TM) Platform SE binary platform does not work" with the text "The resulting problem led to the termination of the program ...".
How to solve this problem, I do not know.
Maybe someone will tell you how to call methods that have been running for quite a long time and, at the same time, the JavaFX application has not been cut down like this ..?
I call the method when selecting the popup menu item:

itemGoIT.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { context.hide(); //убираем меню System.out.println("старт " + new Date(System.currentTimeMillis())); JniTest SS = new JniTest(); try { //вызываем метод SS.showString(); } catch (UnsatisfiedLinkError e) { System.out.println("метод не найден (" + e + ")"); } System.out.println("завершено " + new Date(System.currentTimeMillis())); } }); 
  • show the code where this function is called - Artem Konovalov
  • @Artem Konovalov, supplemented the question with this piece of code - Natalya

1 answer 1

Most likely you suspend the thread handling ui events.
To prevent this from happening, you need to move all heavy operations to a separate thread, i.e. Your code should look like this:

 new Thread(() -> { System.out.println("старт " + new Date(System.currentTimeMillis())); JniTest SS = new JniTest(); try { //вызываем метод SS.showString(); } catch (UnsatisfiedLinkError e) { System.out.println("метод не найден (" + e + ")"); } System.out.println("завершено " + new Date(System.currentTimeMillis())); }).start(); 
  • that is, there will be something like: itemGoIT.setOnAction (new EventHandler () {Override public void handle (Action Event event) {context.hide (); // remove the menu new Thread (() -> {...}) .start ();}); - Natalya
  • or the call of heavy functions should not be called at all when processing ui events? - Natalya
  • if I, when processing an event, launch a new thread in which I call this function, the same thing happens - the application terminates - Natalya
  • @ Natalia means a problem in logic, what is happening there in that operation? - Artem Konovalov
  • This function itself works correctly. I called her in a simple program where there is no GUI - Natalya