Tuesday, August 25, 2009

How to run your Java App using Java Web Start

Java Web Start is a cool way to deploy java applications as there's no need to install the application on users deskstops. All that is needed is a URL that points to a special launch file (JNLP file), it causes the browser to launch Java Web Start, which then automatically downloads, caches, and runs the given Java Technology-based application. The entire process is typically completed without requiring any user interaction, except for the initial single click.

For more details, read this.

1. Export application as a Runnable JAR file e.g. MAMessageEditor.jar





2. Sign the jar. You can view the details here.

Note: If you did not sign the jar, you will get a ecurity error - access denied (java.io.FilePermission)

a. Make sure that you have an SDK 1.4.2 keytool and jarsigner in your path.

b.Create a new key in a new keystore as follows:

keytool -genkey -keystore myKeystore -alias myself

You will get prompted for a information about the new key, such as password, name, etc. This will create the myKeystore file on disk.

c. Then create a self-signed test certificate as follows:

keytool -selfcert -alias myself -keystore myKeystore

This will prompt for the password. Generating the certificate may take a few minutes.

d. Check to make sure that everything is okay. To list the contents of the keystore, use this command:

keytool -list -keystore myKeystore





e. Finally, sign the JAR file with the test certificate as follows:

jarsigner -keystore myKeystore test.jar myself

f. Upload the jar file to the server.


3. Create a JNLP file (see example below). For more details, refer to this link : Deploying Java Web Start Applications

E.g.



codebase="http://invicta.app.vic:8888/abc123/"
href="MAMessageEditor.jnlp">

title Ma Message Editor /title
Masrudyn
Ma Message Editor

Edits MA Message Files








href="http://java.sun.com/products/autodl/j2se"/>




4. Create a HTML page to link to the JNLP file.
E.g.
Launch MA Message Editor

5. Ensure that the destop users has JRE installed.

6. Pass the URL to the users to run the application.

Thursday, August 6, 2009

Configuring Glassfish v2.1 to rotate logs

If you do not configure this, your logs files will grow unbounded:


There's a FAQ to do this:
How do I configure GlassFish to delete rotated log files?

Step 1: Login to Admin Console and navigate to Configuration -> System Properties


Step 2: Add in a new property com.sun.enterprise.server.logging.max_history_files


Step 3: Save and restart Glassfish


If the above does not work, set it via the java options: