Java tips on how to use the JWS network to start deployment software

Source: Internet
Author: User
Tags format java web
Skills | network

Java Network startup (Java Web Start (JWS)) enables you to run all the features of Java applications in a Web browser. Java1.0, which was released by Sun in March 2001, already has support for JWS, and since the j2se1.4 version JWs has become the default configuration for the Java Runtime Environment (Java Runtime Environment (JRE)). You don't have to install it separately, in this article, I'll introduce you to this important technology.

Technology

JWs is a combination of Web browser application software, when the user clicks on the link will point to a Java Network startup protocol (Java Network launching Protocol (JNLP)) file, and then the browser automatically start JWs, and then download, Caching and running application software based on Java technology.

The technology behind JWS is the JNLP and its APIs, which are developed in the Java Community process (Java Community processes). JWs is actually a reference implementation of the JNLP specification, JNLP technology defines a standard file format that describes how to invoke a JNLP file.

Since the installation link can be used as a link to a normal HTTP URL, you can check with the Web page to see if the client has JWs installed, and you can check it in IE with the following code:

       
        
         
        <script language= "VBScript" >on Error Resume NextIf Isie = "true" Then If not (IsObject (CreateObject (  " Javawebstart.isinstalled ")) Then     javawsinstalled = 0  Else     javawsinstalled = 1 End  If if not  ( IsObject (CreateObject ("javawebstart.isinstalled.1.4.2.0")) Then     javaws142installed = 0  Else     javaws142installed = 1 End If is not   (IsObject (CreateObject ("javawebstart.isinstalled.1.5.0.0")) Then     javaws150installed = 0  Else     javaws150installed = 1 end  If End  if</script>
       
        

Development

The development of software deployed on JWS and the development of stand-alone software are essentially the same on the Java 2 platform, for example, the starting point of a program is the following standard code:

public static void Main (string[] argv)

However, in order to support network deployments, that is, to automate downloading and invoking software, and to ensure that the software runs in a secure sandbox, additional considerations are required, including:

The application software must be used as a collection of jar files;

All application resources, such as files and images, must be stored in jar files, and they must be referenced using the getresource mechanism of the Java 2 platform;

Application software can use System.exit call;

Software that makes unrestricted access to the system needs to be used by a signed jar file, and all items in the jar file must be signed;

If the software is to run in a secure sandbox, then it must follow the following restrictions;

Cannot make local disk access;

All jar files must be downloaded from the same host;

Only network connections can be established between the hosts that download the jar files;

Cannot install Security Manager;

Cannot use local class library;

Access to System Properties is limited, and for system properties defined in JNLP, the application can read/write and have the same read-only permission for the same set of attributes as the applet.

Safety

JWs is built on the Java 2 platform, the Java 2 platform provides a comprehensive security architecture, and in Java version 6.0, JWS provides a more powerful security feature, such as code signing.

By default, applications that are invoked via JWS will run in a restricted environment (a "sandbox") that has limited access to local computing resources, such as storage devices and local networks. In this way, JWS guarantees that the downloaded potential untrusted software does not compromise the local file or network.

Of course, an application can also request unrestricted Local system access, in which case, when the software is first invoked, JWS will display a Security Warning dialog box with the contents of the security warning containing information from the software developer.

If an application contains one or more signed jar files, JWS will verify that the jar files have changed since they were signed, and that if the authentication of the digital signature fails, JWS will not run the software because they have been modified by a third party. An application can request full permissions by adding the following settings to the JNLP file.

       
        
         
        <security>   <all-permissions/></security>
       
        

JNLP file

JNLP is a closely related concept with JWS, which can often be used in lieu of the term "network boot", in fact, JNLP is a protocol that prescribes how the JWS application software is started. The JNLP contains the location of the jar package file, the name of the application's primary class, and some other parameters of the program. In an appropriately configured browser, the JNLP file is passed to the JRE, and then the JRE downloads the application to the user's machine and begins execution.

A JNLP file does not contain any binary data, and in fact it contains URLs that point to all binary data and binary code resources. These files can also point to other JNLP files, which are called extension descriptors, and an extended descriptor usually describes the components necessary to run the software, and the resources described in the extension descriptor will become part of the application's classpath, so that the commonly used functionality needs to be described only once. The following example is a common JNLP file:

       
        
         
        <?xml version= "1.0" encoding= "UTF-8"?> <jnlpcodebase= "  Http://www.helloworld.com/hw_app" >    <information>      <title>hello world!</title>      <vendor>my Web company</vendor>      <icon href= "http://www.webjx.com/htmldata/2007-05-22/hello.jpg"/>      <offline-allowed/>    </information>    <resources>      <j2se version= "1.3+"/>      <jar href= "Hw.jar"/ >    </resources>  <application-desc main-class= "Com.helloworld.Hello"/></jnlp>
       
        

This JNLP file describes how to invoke a program named Hello, which requires 1.3 or later Java in the JNLP file to run the program, as well as some program-related information that will be displayed during the user's download.

If you would like to know more about the JNLP protocol and file format, refer to this official specification.

Conclusion

JWS provides a platform-independent, secure and powerful deployment technology, developers only need to deploy the application software on the network server can provide end users with full functionality, and end users can only use a Web browser to run the required applications, and is always the latest version.

One of the main advantages of JWS is that it overcomes the compatibility problems of Java Plug-ins and different Java virtual machines, but programs that use network startup cannot communicate with browsers as easily as applets.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.