How can I run a JavaFX application from a remote PC?

The public knowledge pool and discussion forum of the OWS community. Do not post confidential information here!
TetsutoShikishima
Posts: 4
Joined: 16 Oct 2022, 11:16

How can I run a JavaFX application from a remote PC?

Post by TetsutoShikishima »

Hi!

The OpenWebStart FAQ says that OpenWebStart can run OpenJFX-based JavaFX applications, but I get the following error at "launch" when calling JavaFX from Java:

Launch exception
netx: Launch Error: Could not launch JNLP file. ((access denied ("java.lang.RuntimePermission" "getClassLoader")))
Denying permission: ("java.lang.RuntimePermission" "getClassLoader")

It works fine on localhost, but when I call JavaWebStart from a remote PC, I get the above error.
The version of JavaFX is 17.

Also, the source code is as follows.

package OpenWebStart;

import javafx.application.Application;
import javafx.stage.Stage;

public class FXWebStart extends Application {

public static void main(String[] args) {

System.out.println(">>> Execute Launch");
launch(args);
}

public void start(Stage primaryStage) {

System.out.println(">>> Start JavaFX");

}

}

How can I run a JavaFX application using OpenWebStart from a remote PC?

Thank you

Janak Mulani
Posts: 726
Joined: 24 Mar 2020, 13:37

Re: How can I run a JavaFX application from a remote PC?

Post by Janak Mulani »

By remote PC do you mean that the server hosting the jnlp file is on one machine and you are accessing the jnlp file by its url from another machine?

https://openwebstart.com/docs/FAQ.html# ... enwebstart

As the above doc says you will have to wrap your JavaFx app in a Launcher class and use the Launcher class in the Jnlp file.

I hope this helps.

TetsutoShikishima
Posts: 4
Joined: 16 Oct 2022, 11:16

Re: How can I run a JavaFX application from a remote PC?

Post by TetsutoShikishima »

Thank you for your advice.

>By remote PC do you mean that the server hosting the jnlp file is on one machine and you are accessing the jnlp file by its url from another machine?

That's right.
I tried various things by modifying the code with reference to the URL you gave me, but the situation does not change.
">>> Execute Launch" is displayed, but an error occurs in the launch method and ">>> Start JavaFX" is not displayed.
What am I doing wrong?

The source code is below.
It made no difference whether I created each jar file from the classes below or combined them into one.

// Launcher for JavaFX application which is specified in the Jnlp file
package OpenWebStart;
public class FXWebStartLauncher {
public static void main(String[] args) {
FXWebStart.main(args);
}
}
// JavaFX Application
package OpenWebStart;
import javafx.application.Application;
import javafx.stage.Stage;
public class FXWebStart extends Application {
public static void main(String[] args) {
System.out.println(">>> Execute Launch");
launch(args);
}
@Override
public void start(Stage primaryStage) {
System.out.println(">>> Start JavaFX");
}
}

Thank you.

Janak Mulani
Posts: 726
Joined: 24 Mar 2020, 13:37

Re: How can I run a JavaFX application from a remote PC?

Post by Janak Mulani »

Did you specify FXWebStartLaunche in your Jnlp file?

TetsutoShikishima
Posts: 4
Joined: 16 Oct 2022, 11:16

Re: How can I run a JavaFX application from a remote PC?

Post by TetsutoShikishima »

Thank you Janak.

Of course, I specify FXWebStartLaunche.jar in my JNLP file.
The message ">>> Execute Launch" before the "launch" method is displayed, and FXWebStartLaunche.jar itself is being called from JNLP and executed.

Then the following error occurs when the "launch" method is executed.
Launch exception
netx: Launch Error: Could not launch JNLP file. ((access denied ("java.lang.RuntimePermission" "getClassLoader")))
Denying permission: ("java.lang.RuntimePermission" "getClassLoader")

I tried setting the server's address in the whitelist of itw-settings.exe on the remote PC, but the situation did not change.
By the way, when I use Swing instead of JavaFX, it works fine.

Please let me know if there is anything else I should check.

thank you in advance

Janak Mulani
Posts: 726
Joined: 24 Mar 2020, 13:37

Re: How can I run a JavaFX application from a remote PC?

Post by Janak Mulani »

You say "Of course, I specify FXWebStartLaunche.jar in my JNLP file." But did you specify the Launcher class in the application tag?

Please share your jnlp file.

TetsutoShikishima
Posts: 4
Joined: 16 Oct 2022, 11:16

Re: How can I run a JavaFX application from a remote PC?

Post by TetsutoShikishima »

Thank you Janak

The JNLP file is as follows.
By the way, the simple code I showed before gives an error with Open Web Start (1.6.0), but works fine with IcedTea-Web (1.8.8).

<?xml version="1.0" encoding="utf-8"?>
<jnlp
spec="1.0+"
codebase="http://192.168.11.5/OWSsample">

<information>
<title>Open Web Start Sample</title>
<vendor>KaRaKun</vendor>
<offline-allowed/>
</information>

<security>
<all-permissions/>
</security>

<resources>
<j2se version="17*" />
<jar href="FXWebStartLauncher.jar"/>
<jar href="FXWebStart.jar"/>
<jar href="FXWebStart_lib\commons-codec-1.15.jar"/>
<jar href="FXWebStart_lib\javafx.base.jar"/>
<jar href="FXWebStart_lib\javafx.controls.jar"/>
<jar href="FXWebStart_lib\javafx.fxml.jar"/>
<jar href="FXWebStart_lib\javafx.graphics.jar"/>
<jar href="FXWebStart_lib\javafx.media.jar"/>
<jar href="FXWebStart_lib\javafx.swing.jar"/>
<jar href="FXWebStart_lib\javafx.web.jar"/>
<jar href="FXWebStart_lib\javafx-swt.jar"/>
</resources>

<application-desc main-class="OpenWebStart.FXWebStartLauncher"/>
</jnlp>

Thank you

Post Reply