Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 3 of 4
Unlike appletviewer, which recognizes policy files, Internet browsers require applets to be digitally signed. For the purpose of this article,
a self-signed test certificate is sufficient. Carry out the following steps to create a new key and keystore on which the
certificate is based, create this certificate, sign Weather.jar, and sign the javafxrt.jar and Scenario.jar files:
keytool -genkey -keystore myKeyStore -alias memyKeyStore) is self-signed so that you don't accidentally put it into production.keytool program prompts you for information about the new key: It asks you for a password to protect the keystore. Then it asks you
for your first and last name, the name of your organizational unit, the name of your organization, the name of your city or
locality, the name of your state or province, and the two-letter code of your country. If the values you've entered are correct,
respond with yes to the "Is...correct?" prompt. Finally, press Enter to assign the keystore password as the password for the key.
keytool -selfcert -alias me -keystore myKeyStorejarsigner -keystore myKeyStore Weather.jar mejarsigner program updates the JAR file's META-INF directory to contain certificate information and digital signatures for each entry in the archive. If all goes well, you
end up with a signed Weather.jar file.
jarsigner -keystore myKeyStore Scenario.jar me and jarsigner -keystore myKeyStore javafxrt.jar meBefore we explore applet deployment via the Java Deployment Toolkit, I recommend uninstalling any Java Runtime Environments (JREs) for Java SE 6 that are installed on your platform, because the expected behavior shown in the following section will probably differ if one of these JREs is present. You shouldn't need to uninstall any installed Java SE 6 JDKs (with their private JREs).
The Java Deployment Toolkit includes a deployJava.js JavaScript file whose runApplet(attributes, parameters, minimumversion) function simplifies the task of deploying an applet. Furthermore, this function ensures that an appropriate version of the
Java runtime is installed before running the applet. Listing 4 demonstrates runApplet() in the context of the Weather applet.
<html>
<head>
<script src="http://java.com/js/deployJava.js">
</script>
</head>
<body>
<script>
var attributes =
{
code: 'javafx.ui.Applet',
width: 375,
height: 375,
archive: 'javafxrt.jar,Scenario.jar,Weather.jar'
};
var parameters =
{
AppletClass: 'Weather',
image: 'title.jpg'
};
var version = '1.6.0';
deployJava.runApplet (attributes, parameters, version);
</script>
</body>
</html>
The attributes parameter specifies the same <applet> tag attributes that were revealed in Listing 3. Similarly, parameters specifies the same AppletClass parameter, but also specifies an image parameter for replacing the startup Java animation (which is displayed before the applet loads) with a custom image (in title.jpg). Finally, parameter version identifies the minimum Java version needed to run the applet.
To experiment with the default installer, point your browser to Weather2default.html. For example, after pointing Mozilla Firefox 3 to this file, this browser presented the content shown in Figure 2.
Click the Download Now button to continue. In response, Firefox presents a message box for obtaining an installer program
called jxpiinstall.exe, as Figure 3 reveals.
Click Save File to save jxpiinstall.exe to your desktop. Then double-click the icon that's created on your desktop to begin the installation. Figure 4 presents the
initial dialog box.
Accept the license agreement by clicking the Accept button. Assuming that you haven't checked the "Show advanced options" panel, this leads you to Figure 5's Java Setup dialog box.
Click the Finish button on the final Java Setup - Complete dialog box to quit the installer. At this point, update 5 has been completely installed.
Because the browser doesn't automatically start running the applet, you need to once again point the browser to Weather2default.html. This time, you should see the content shown in Figure 6.
Technology downloads
openjdk-compiler-weekly-2008-04-14.zip or openjdk-compiler-weekly-2008-04-14.tgz)
More from JavaWorld
Archived Discussions (Read only)