Tutorial 4: Performance Improvements
Written by Chad on September 17th, 2008This tutorial post will be more a rehash of Tutorial 1 to make it better. This tutorial is built on the work of WorldWind forum member Nicolas Castel and his changes that have made some noticeable changes for the better. For these changes to work, you need Java SE update 10 installed (Otherwise nothing will show).
The first change will be in the applet code block, it goes from 9 lines down to three lines:
<applet id="wwjApplet" name="wwjApplet" mayscript code="gov.nasa.worldwind.examples.applet.WWJApplet" width=100% height=70% > <param name="jnlp_href" value="wwjapplet.jnlp"> </applet>
All the settings for the applet are now called by the wwjapplet.jnlp file, and that file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<jnlp href="wwjapplet.jnlp">
<information>
<title>World Wind Java New Plugin Applet Demo</title>
<vendor>NASA</vendor>
<homepage href="http://worldwind.arc.nasa.gov"/>
<description>World Wind Java New Plugin Applet Demo</description>
<description kind="short">World Wind Java New Plugin Applet Demo</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.5+" initial-heap-size="512m"
max-heap-size="512m"/>
<property name="sun.java2d.noddraw" value="true"/>
<jar href="http://worldwind.arc.nasa.gov/java/demos/WWJApplet.jar" main="false"/>
<jar href="http://worldwind.arc.nasa.gov/java/demos/worldwind.jar" main="false"/>
<extension name="jogl"
href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp"/>
</resources>
<applet-desc
name="My Applet"
main-class="gov.nasa.worldwind.examples.applet.WWJApplet"
width="300"
height="300">
<param name="MAYSCRIPT" value="true"/>
</applet-desc>
</jnlp>
JNLP (Java Network Launch Protocol) is an XML-based protocol that can be used to deploy Java and JavaFX applications on the Internet.
One of the benefits of this is the ability to manage the memory allocated to the applet using this line:
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.5+" initial-heap-size="512m" max-heap-size="512m"/>
With using the JNLP syntax, I have noticed that the WWJava applet does load faster and is more stable.
The final applet web page now look like this:
<html> <head> <title>NASA World Wind Java Applet</title> </head><body> <applet id="wwjApplet" name="wwjApplet" mayscript code="gov.nasa.worldwind.examples.applet.WWJApplet" width=600 height=380 > <param name="jnlp_href" value="wwjapplet.jnlp"> </applet> </body> </html>
See this tutorial in use.
