Example of Signed Java DTV Application

Supposing a simple Hello DTV Application:
package hello;

import javax.microedition.xlet.*;

public class HelloXlet implements Xlet {
    XletContext ctx;

    public void destroyXlet(boolean arg0) throws XletStateChangeException {
        // Empty
    }

    public void initXlet(XletContext ctx) throws XletStateChangeException {
        this.ctx = ctx;
    }

    public void pauseXlet() {
        // Empty
    }

    public void startXlet() throws XletStateChangeException {
        System.out.println("Hello Java DTV.");
        ctx.notifyDestroyed();
    }

} 

Use a simple manifest.mf that identifies the main entry class.

Main-Class: hello.HelloXlet

Create the JAR file using the normal jar tool. Then sign with the jarsigner tool using the certificate in the keystore with the alias mykey.

% jar -cfm hello.jar manifest.mf -C classes hello
% jarsigner hello.jar mykey -storepass xxx

The hello.jar now contains the classes and authentication files.

META-INF/MANIFEST.MF
META-INF/MYKEY.SF
META-INF/MYKEY.DSA
META-INF/
hello/
hello/HelloXlet.class

The generated MANIFEST.MF contains the main attributes and entries for each file.

Manifest-Version: 1.0
Created-By: 1.5.0_16-133
Main-Class: hello.HelloXlet

Name: hello/HelloXlet.class
SHA1-Digest: IAhtIdnN9ITtPFY2nIb8NHjXYC0=   

The mykey.sf file contains:

Signature-Version: 1.0
Created-By: 1.5.0_16 
SHA1-Digest-Manifest-Main-Attributes: 80psXuLFfIvDp8Uj/StiEb4uVEs=
SHA1-Digest-Manifest: gGhmIOAW3WJ2cmhf+XsPVg8F+uk=
    
Name: hello/HelloXlet.class
SHA1-Digest: BgKfgpXw6c/geXKxU9SyI3h/VUQ=