rajuthoutu
rajuthoutu

Reputation: 188

How to deploy and run javafx application in tomcat

I have a requirement in my application ,Running the javafx application in browser from web-server. how can i achieve this thing.

Thanks in advance.

Upvotes: 3

Views: 10518

Answers (1)

jewelsea
jewelsea

Reputation: 159291

Solution

Place a copy of the jar, jnlp and html file output by the NetBeans build into a directory of your webserver, then access the html file in your browser.

For example, let's say you called your application MyPowerApp and netbeans output MyPowerApp.html and you wanted to deploy that to a local Tomcat server.

  1. Download and install a copy of Tomcat (http://tomcat.apache.org/download-70.cgi)
  2. Copy the jar, jnlp and html file into tomcat's webapps/ROOT directory.
  3. Start tomcat.
  4. Access your application via http://localhost:8080/MyPowerApp.html

The applet will start automatically and you can click on the link to launch the application via WebStart.

To update the application just rebuild it in NetBeans, copy it over into the tomcat webapps/ROOT directory and refresh your browser link (no need to restart Tomcat).

In practice you will want to modify the html rather than use the generated html to embed either the applet or WebStart link somewhere on your website (you won't need both execution modes in a single page like the Netbeans generated sample).

Background

JavaFX applications do not run in Tomcat.

Tomcat can be used to host a html page embedding a JavaFX application jar. A browser with the JavaFX plugin installed and activated can download the the JavaFX application from Tomcat and execute the application in the browser window using a Java runtime environment installed on the client browser machine. See the JavaFX Deployment Guide for more details and the JavaFX deployment quick start for short info on getting started.

Note that getting JavaFX to work correctly in a browser across a wide range of client machines may prove a difficult task for you, so you may want to investigate alternate deployment methods as outlined in the JavaFX deployment guide (such as WebStart, Standalone or Self-contained application deployment modes).

Upvotes: 5

Related Questions