With browsers being more and restrictive when it comes to running applets, it is recommended to move your applet to jnlp.

If you have existing applets, you do not need to change any Java line to launch with Webstart (jnlp). You can use the applet-desc tag within the jnlp file.

For example, we have converted our Java applet “SaveToWeb” contained in webnotes.jar so that instead of being launched from html, it is being launched with jnlp. The “SaveToWeb” applet opens a PDF file from our server, allows users to edit and annotate the PDF document and then save the file back to the server by calling the upload.php script located on our server.

Original Applet .html File:

<HTML>
<HEAD>
<title>Qoppa Software - jPDFNotes Applet</title>
<script src="https://java.com/js/deployJava.js"></script>
</HEAD>
<BODY>
<font size="5"><strong>jPDFNotes - Applet Save to Web Server</strong></font>
<hr>
<script>
 
  var parameters = {
  OpenURL:"serverfiles/sample01.pdf", 
  SaveURL:"upload.php", 
  OpenVisible:"false", 
  java_arguments:"-Xmx256m"};
 
  var attributes = {
  archive:"/files/pdfnotes/jars/webnotes.jar,/files/pdfnotes/jars/jPDFNotes.jar", 
  code:"qoppa.webNotes.SaveToWeb", 
  width:"100%", 
  Height:"95%", 
  name:"jPDFNotes"};
  var version = "1.6.0";
 
  deployJava.runApplet(attributes, parameters, version);
</script>
<hr>
</BODY>
</HTML>

Try this applet live!

New Webstart .jnlp File:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.5" codebase="http://www.qoppa.com/files/pdfnotes/demo" 
href="jPDFNotes_savetoweb.jnlp">
   <information>
      <title>jPDFNotes WebStart Demo</title>
      <vendor>Qoppa Software, LLC</vendor>
      <description>jPDFNotes WebStart Demo</description>
      <homepage href="http://www.qoppa.com/pdfnotes/"/>
      <description kind="short">jPDFNotes is a Java bean to view and annotate PDF files in Java applications.</description>
      <offline-allowed/>
   </information>
   <security>
      <all-permissions/>
   </security>
   <resources>
 <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" max-heap-size="256m"/>
      <jar href="/files/pdfnotes/jars/jPDFNotes.jar"/>
      <jar href="/files/pdfnotes/jars/webnotes.jar" main="true"/>
   </resources>
   <applet-desc
      documentBase="http://www.qoppa.com/pdfnotes/"
name="jPDFNotes"
main-class="qoppa.webNotes.SaveToWeb"
	  width="100%" 
	  height="95%">
    <param name="OpenURL" value="serverfiles/sample02.pdf"/>
    <param name="SaveURL" value="upload.php"/>
    <param name="OpenVisible" value="false"/>
    <param name="java_arguments" value="-Xmx256m"/>
  </applet-desc>
</jnlp>

Try this jnlp file live!

Here are conversion tips from converting your html applet to jnlp Webstart:

  • jars under archive move to resources
  • the main class move from code to main-class
  • the var parameters become param elements

The webstart-launched applet will open in its own frame, we were unable to show the applet within a new or existing HTML page. We tried using the documentBase parameter without success. If you succeed in showing the applet inside an HTML page, please let us know so we can update this KB entry.