JNLP (Java Network Launch Protocol) is an XML-based protocol that can be used to deploy Java and JavaFX applications on the Internet.
Here is the JNLP file to deploy the JavaFXPad (http://download.java.net/general/openjfx/demos/javafxpad.jnlp):
<?xml version="1.0" encoding="utf-8"?>
<jnlp
spec="1.5+"
codebase="http://download.java.net/general/openjfx/demos"
href="javafxpad.jnlp">
<information>
<title>JavaFX Demos:JavaFX Pad</title>
<vendor>Sun Microsystems</vendor>
<offline-allowed />
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se"
java-vm-args="-Xss1M -Xmx256M"
>
</j2se>
<jar href="javafxrt.jar" main="true"/>
<jar href="Filters.jar"/>
<jar href="swing-layout.jar"/>
<jar href="javafxpad.jar"/>
</resources>
<application-desc main-class="net.java.javafx.FXShell">
<argument>javafxpad.Main</argument>
</application-desc>
</jnlp>
Hello Web Start FX example (Compiler)[]
Requirements[]
- Java 5+ JDK
dist/lib/javafxrt.jar
anddist/lib/javafxgui.jar
from the JavaFX Script Compiler
Compile Hello Web Start JFX[]
Filename: hellowebstart.fx
package hellowebstart;
import javafx.gui.*;
import java.lang.System;
Frame {
closeAction: function(): Void {System.exit(0);}
background : Color.WHITE;
title : 'Hello Web Start JFX!'
visible: true
content: Label{
text: 'Hello Web Start JFX!'
font: Font{size: 32}
}// Label
}// Frame
webstartcompiler/hellowebstart$ javafxc -target 1.5 hellowebstart.fx
Create hellowebstart.jar[]
webstartcompiler/hellowebstart$ cd ..
webstartcompiler$ jar cvf hellowebstart.jar hellowebstart/*.class
Create hellowebstart.jnlp[]
Filename: hellowebstart.jnlp
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.5+"
codebase="http://www.example.com/webstartcompiler/"
href="hellowebstart.jnlp">
<information>
<title>Hello Web Start JFX!</title>
<vendor>John Doe</vendor>
<homepage href="http://www.example.com/webstartcompiler/"/>
<description>Java Web Start example for the JavaFX Script Compiler.</description>
<offline-allowed/>
</information>
<resources>
<j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se">
</j2se>
<jar href="javafxrt.jar" main="false"/>
<jar href="javafxgui.jar" main="false"/>
<jar href="hellowebstart.jar" main="true"/>
</resources>
<application-desc main-class="hellowebstart.hellowebstart">
</application-desc>
</jnlp>
Set link to hellowebstart.jnlp[]
Filename: index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hello Web Start JFX!</title>
</head>
<body>
<h1>Hello Web Start JFX!</h1>
<p><a href="hellowebstart.jnlp">Java Web Start: Hello Web Start JFX!</a></p>
</body>
</html>
Webserver: Set MIME type for .jnlp[]
Apache: http.conf or .htaccess.
AddType application/x-java-jnlp-file JNLP
Copy files on webserver[]
Copy files on the webserver with FTP or in this case with cp
for server on the local machine.
webstartcompiler$ mkdir /www/www.example.com/docs/webstartcompiler/
webstartcompiler$ cp index.html hellowebstart.jnlp hellowebstart.jar javafxrt.jar javafxgui.jar /www/www.example.com/docs/webstartcompiler/
Start[]
Web Start via www.example.com/webstartcompiler/
Hello Web Start FX example (Interpreter)[]
License[]
License see FAQ#What_is_the_licencing_model.3F.
Requirements[]
- Java 5 JDK
- /lib/javafxrt.jar and lib/swing-layout.jar from the openjfx packet
Hello Web Start JFX[]
Filename: HelloWebStart.fx
import javafx.ui.*;
Frame {
title : 'Hello Web Start JFX!'
width : 600
height : 400
content: Label {
text: 'Hello Web Start JFX!'
font: Font{size: 32}
}
visible: true
}
Create HelloWebStartJFX.jar[]
jar cvf HelloWebStartJFX.jar HelloWebStart.fx
Create HelloWebStartJFX.jnlp[]
Filename: HelloWebStartJFX.jnlp
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.5+"
codebase="http://www.example.com/HelloWebStartJFX/"
href="HelloWebStartJFX.jnlp">
<information>
<title>Hello Web Start JFX</title>
<vendor>John Doe</vendor>
<homepage href="http://www.example.com/HelloWebStartJFX/"/>
<description>Web Start example for JavaFX Scripts</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se">
</j2se>
<jar href="javafxrt.jar" main="true"/>
<jar href="swing-layout.jar"/>
<jar href="HelloWebStartJFX.jar"/>
</resources>
<application-desc main-class="net.java.javafx.FXShell">
<argument>HelloWebStart</argument>
</application-desc>
</jnlp>
Create signature key[]
keytool -genkey -alias jfx -dname "CN=John Doe, O=JFX Inc." -validity 9999 -keystore jfx.keystore -keypass keyPassword -storepass storePassword
Sign .jars[]
jarsigner -keystore jfx.keystore -verbose -keypass keyPassword -storepass storePassword HelloWebStartJFX.jar jfx
jarsigner -keystore jfx.keystore -verbose -keypass keyPassword -storepass storePassword javafxrt.jar jfx
jarsigner -keystore jfx.keystore -verbose -keypass keyPassword -storepass storePassword swing-layout.jar jfx
Set link to HelloWebStartJFX.jnlp[]
Filename: index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hello Web Start JFX!</title>
</head>
<body>
<h1>Hello Web Start JFX!</h1>
<p><a href="HelloWebStartJFX.jnlp">Java Web Start: Hello Web Start JFX!</a></p>
</body>
</html>
Webserver: Set MIME type for .jnlp[]
Apache: http.conf or .htaccess.
AddType application/x-java-jnlp-file JNLP
Copy files on webserver[]
Copy files on the webserver with FTP or in this case with cp
for server on the local machine.
mkdir /www/www.example.com/docs/HelloWebStartJFX/
cp index.html HelloWebStartJFX.jnlp HelloWebStartJFX.jar javafxrt.jar swing-layout.jar /www/www.example.com/docs/HelloWebStartJFX/
Start[]
Web Start via www.example.com/HelloWebStartJFX/