Distributing the Java Web start application via CD-ROM

Source: Internet
Author: User
Tags require resource java web

As we all know, Java Web Start (JWS) supports distributing applications in a web-based manner. So why do you want to distribute the Java Web Start (JWS) application over the CD-ROM? There are many reasons for this. For larger applications, a full installation can be a pet-heavy download task, even with high-speed bandwidth. Second, not all desktop systems are online and do not necessarily have access to the Internet (for example, the security of the company). Finally, some people just like to use CDs.

A client company has asked to distribute their applications anywhere in the world, including where broadband is not covered. The application contains information about a large number of products, including detailed charts. All this information constitutes a major part of the application, and a full installation, including the JVM, will exceed MB. In addition, the company also wants to be able to distribute applications through CDs at trade fairs with promotional materials, so it is very necessary to distribute CDs based. Typically, a CD installation can take a commercial or open source installation program, and these installers abound. However, when running an application with Java Web Start, the application needs to be installed in a specific location without the user's will to control it, as set out in the installer.

This article describes how to install an application from a CD or the Internet. The installation process has the following requirements:

The installed application checks for updates and integrates with the JWS cache.

The installation should be done on a machine that does not have Java installed.

An installed application should not require an Internet connection.

The installation must be easy to use and must provide a simple user interface.

Application installations are typically performed by common installers, but the traditional installation process effectively creates a separate, JWS-unaware application. Each time the update is released, the user needs to download and install the new version, and the JWS application only needs to download the updated component, which is more efficient and reliable. Therefore, this article also describes the installer for the JWS application.

JWS Primer

Java Web Start allows you to start a Java application by linking to a JNLP file. The JNLP file describes the entry point of the main method or application and references the resources used by the application.

When the JWS application starts, the JVM attempts to access the required resources, updates them as needed, and then copies the files to the cache. When you then try to start the application, JWS can check the cache and skip the resource download step. If the client machine is offline, or if the server cannot be connected, JWS can run the application in offline mode.

If the JWS startup file (JNLP) is saved on the CD, JWS will contact the server and download any new files. Obviously, if the client machine is online, this will destroy the plan to distribute the files through the CD. Instead, we need to take some methods to update the JWS cache as if the application had been preloaded by JWS.

Update JWS Cache

The Java 5 version of JWS contains a-import option to import JWS applications in a specific location into the cache.

The CD image at this location is just a copy of the WEB server: The JNLP file, the. jar file, and the resource referenced by the JNLP file. If you use the servlet to service this JNLP, the CD image will require a full-featured snapshot of the JNLP file that is generated.

Therefore, you can install the CD image into the JWS cache by calling the following command:

<java_home>/jre/bin/javaws-codebase <CACHE_IMAGE>-Import <CACHE_IMAGE>/<XXXX>.JNLP

Where,<java_home> is the root of the JVM,<cache_image> is where the JWS application is located on the CD, and <XXXX> is the name of the application JNLP file. Later, we'll explain how to automate this command and wrap it in a simple GUI.

When you install an application in the cache, JWS prompts the user to install the desktop and menu shortcuts for the startup application. After completing the JWS installation, we can call JWS to launch the most recently installed application.

<java_home>/jre/bin/javaws-import <CACHE_IMAGE>/<XXXX>.JNLP

This will use the CD again, but JWS will use the JNLP file reference installation this time. If the machine is connected to the Internet, it will check for updates in the usual way and then start the application. If there is no network connection, the application starts on a CD-delivered standard.

The next time the user starts the application, they can use the menu or desktop shortcuts instead of the CD. Alternatively, the user can start the application by using a link on the page that points to the same URL/JNLP file combination: The original version on the site.

JVM factors

One problem throughout the process is that the above commands require JVM support, and in a few cases the JVM may not be installed by default in the system or the JVM is not available in the system path, so there are some additional steps that need to be taken to locate the available JVM. Additionally, when a user inserts a CD, the installer should be able to start and check if the JVM already exists. The process of checking the JVM is as follows:

Check the JVM (for setup).

If the JVM is not detected, install it.

Start the installer to display the usual license information.

Install the target JVM (if required by the application).

Import the JWS cache.

Start the JWS application.

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.