Movatterモバイル変換


[0]ホーム

URL:


Documentation

The Java™ Tutorials
Doing More With Java Rich Internet Applications
Setting Trusted Arguments and Secure Properties
System Properties
JNLP API
Accessing the Client Using JNLP API
Cookies
Accessing Cookies
Security in Rich Internet Applications
Guidelines for Securing Rich Internet Applications
Questions and Exercises
Trail: Deployment
Lesson: Doing More With Java Rich Internet Applications
Home Page >Deployment >Doing More With Java Rich Internet Applications
« Previous • Trail • Next »

The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.
SeeDev.java for updated tutorials taking advantage of the latest releases.
SeeJava Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.
SeeJDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.

Setting Trusted Arguments and Secure Properties

You can set certain Java Virtual Machine arguments and secure properties for your rich Internet application (RIA) in the RIA's Java Network Launch Protocol (JNLP) file. For applets, you can also set arguments in thejava_arguments parameter of the<applet> tag. Although there is a predefined set of secure properties, you can also define new secure properties by prefixing the property name with "jnlp." or "javaws.". Properties can be retrieved in your RIA by using theSystem.getProperty method.

Consider the Properties and Arguments Demo applet. The following Java Virtual Machine arguments and properties are set in the applet's JNLP file,appletpropsargs.jnlp.

<?xml version="1.0" encoding="UTF-8"?><jnlp spec="1.0+" codebase="" href="">    <information>        <title>Properties and Arguments Demo Applet</title>        <vendor>Dynamic Team</vendor>    </information>    <resources>        <!-- Application Resources -->        <j2se version="1.6+"              href="http://java.sun.com/products/autodl/j2se"              <!-- secure java vm argument -->              java-vm-args="-Xmx256M"/>        <jar href="applet_PropertiesAndVMArgs.jar"            main="true" />            <!-- secure properties -->        <property name="sun.java2d.noddraw"            value="true"/>        <property name="jnlp.myProperty"            value="a user-defined property"/>    </resources>    <applet-desc          name="Properties and Arguments Demo Applet"         main-class="PropertiesArgsDemoApplet"         width="800"         height="50">                  </applet-desc>     <update check="background"/></jnlp>

ThePropertiesArgsDemoApplet class uses theSystem.getProperty method to retrieve thejava.version property and other properties that are set in the JNLP file. ThePropertiesArgsDemoApplet class also displays the properties.

import javax.swing.JApplet;import javax.swing.SwingUtilities;import javax.swing.JLabel;public class PropertiesArgsDemoApplet extends JApplet {    public void init() {        final String javaVersion = System.getProperty("java.version");        final String  swing2dNoDrawProperty = System.getProperty("sun.java2d.noddraw");        final String  jnlpMyProperty = System.getProperty("jnlp.myProperty");                try {            SwingUtilities.invokeAndWait(new Runnable() {                public void run() {                    createGUI(javaVersion, swing2dNoDrawProperty, jnlpMyProperty);                }            });        } catch (Exception e) {            System.err.println("createGUI didn't successfully complete");        }    }    private void createGUI(String javaVersion, String swing2dNoDrawProperty, String jnlpMyProperty) {        String text = "Properties: java.version = " + javaVersion +                 ",  sun.java2d.noddraw = " + swing2dNoDrawProperty +                ",   jnlp.myProperty = " + jnlpMyProperty;        JLabel lbl = new JLabel(text);        add(lbl);    }}

The Properties and Arguments Demo applet is shown next. You can also see the applet running inAppletPage.html.


Note:  If you don't see the applet running, you need to install at least theJava SE Development Kit (JDK) 6 update 10 release.

Note:  If you don't see the example running, you might need to enable the JavaScript interpreter in your browser so that the Deployment Toolkit script can function properly.

Download source code for theProperties and Arguments Demo Applet example to experiment further.

SeeSystem Properties for a complete set of system properties that can be accessed by RIAs.

« PreviousTrailNext »

About Oracle |Contact Us |Legal Notices |Terms of Use |Your Privacy Rights

Copyright © 1995, 2024 Oracle and/or its affiliates. All rights reserved.

Previous page: Doing More With Java Rich Internet Applications
Next page: System Properties

[8]ページ先頭

©2009-2025 Movatter.jp