Click here to Skip to main content
13,449,422 members (42,488 online)
Click here to Skip to main content
Add your own
alternative version


16 bookmarked
Posted 31 Aug 2004

How to Develop a Signed Applet

, 31 Aug 2004
Rate this:
Please Sign up or sign in to vote.
Read/write the local machine file system using a signed applet


The information in this article helps in answering the following questions:

  • What are the tools needed to develop a signed applet?
  • How to make a test certificate using Microsoft Sign Tool?
  • How to read/write the local machine file system using a signed applet?


This article shows how to develop a signed applet using the Microsoft sign Tool.

Reading and writing file system through an applet is possible provided you have signed that applet using Microsoft Sign tool for Internet Explorer or Netscape sign tool for Netscape. The example that I showed here is just an example of how to create a test certificate. This is not recommended if you are going to publish your applet over the Web. In that case, you will have to get the certificate from Verisign or Thawte certificate for publishing. Unless the content in your applet is insecure, it may corrupt itself or corrupt other resources where it is playing.

Tools Required

  • Microsoft Internet Explorer 3.0 or upgrade version
  • Microsoft Sign tool which encompasses the following EXEs and DLLs
    • makecert.exe
    • signcode.exe
    • setreg.exe
    • ChkTrust.exe
    • cert2spc.exe
    • cabarc.exe
    • javasign.dll
    • signer.dll
    • com package

More Information

Part I: Java Applet Read/Write File System using Applet

Part I provides the source code for the read/write applet.

import java.applet.*;
import java.awt.*;
import java.lang.*;
import java.applet.*;

public class WriteFile extends Applet 
    String myFile = "G:\\";
    File f = new File(myFile);
    DataOutputStream dos;

    public void paint(Graphics g) 
          //create the output stream    
          dos = new DataOutputStream(new BufferedOutputStream
                (new FileOutputStream(myFile),128));
          //write chars to that file        
          dos.writeChars("Cats can hypnotize you when you least expect it\n");
          //flush stream to that file
          g.drawString("Successful attempt to write to " + myFile, 10, 10);
        catch (SecurityException e) 
              g.drawString("writeFile: caught security exception", 10, 10);
            }catch (IOException ioe) 
        g.drawString("writeFile: caught i/o exception", 10, 10);

Part II: How to Make Test Certificate using Microsoft Sign Tool

Part II provides step by step instructions on how to make a test certificate and embed with an applet in HTML.

To make a test certificate, follow the steps given below:

  1. Extract containing all sign tool components and two batch files for executing the EXEs.
  2. The sign.bat file looks like this:
    makecert /sv "WriteFile.pvk" /n "CN=WriteFile" WriteFile.cer
    cert2spc WriteFile.cer WriteFile.spc setreg 1 true
    appsign c:\Test\SignedApplet\WriteFile WriteFile low 
  3. Here you are going to create the private key named WriteFile.pvk and certificate name WriteFile.cer and you have to note where to create that certificate. Here I mentioned c:\test\signedapplet is the folder.
  4. The appsign.bat look like this:
    SET CERT_FILE="c:\Test\SignedApplet\WriteFile.spc"
    SET KEY_FILE="c:\Test\SignedApplet\WriteFile.pvk"
    cabarc -s 6144 N WriteFile.class 
    signcode -j javasign.dll -jp %3 -spc %CERT_FILE% -v %KEY_FILE% -n %2
  5. Here you have mentioned the class files as an argument of cabarc. We are going to create a CAB file name called
  6. First, compile
  7. Write sign in command prompt and enter.
  8. Sign tool will ask create private key password and confirm password. Write 'test' and 'test' and anything you wish and click ok.
  9. Again for private key password write 'test'.
  10. Then it will ask for the publisher key password, write 'test' or anything you wish.
  11. You will get the message in the command prompt like this:
    "This file is signed, but not timestamped"- leave the warning.
  12. Let's make an HTML file like this:
    <applet code="WriteFile.class" width =200 height=200>
    <param name="CABBASE" value="">
  13. Open it in Internet Explorer. The file is signed and you can get the message in an applet as follows "successful attempt to write to " drive name (where you mentioned).


  • 1st September, 2004: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ashraf Mohamed
Web Developer
United States United States
I am a system analyst and have been with Microsoft & Sun Technologies for more than 7 years. I have always been fascinated by java and .NET. I take lot of technical articles and writing them.

I am a Sun Certified Java Programmer for Java 2 Platform 1.4 , Web component developer Java 2 Platform - Enterprise Edition 1.4 and Microsoft certified developer using C#.NET in Web Development ASP.NET.

Visit my web site

You may also be interested in...


Comments and Discussions

GeneralError: Signing Failed..... Pin
Ra...aj19-Apr-07 1:55
memberRa...aj19-Apr-07 1:55 
GeneralRe: Error: Signing Failed..... Pin
Mohamed Ashraf19-Apr-07 2:58
memberMohamed Ashraf19-Apr-07 2:58 
GeneralRe: Error: Signing Failed..... Pin
Ra...aj19-Apr-07 3:42
memberRa...aj19-Apr-07 3:42 
GeneralRe: Error: Signing Failed..... Pin
Ashraf Mohamed5-Jul-07 17:01
memberAshraf Mohamed5-Jul-07 17:01 
GeneralProblems regarding Unsigned ActiveXControl Pin
justindhas4-Apr-07 2:03
memberjustindhas4-Apr-07 2:03 
GeneralRe: Problems regarding Unsigned ActiveXControl Pin
Mohamed Ashraf4-Apr-07 2:21
memberMohamed Ashraf4-Apr-07 2:21 
GeneralRe: Problems regarding Unsigned ActiveXControl Pin
justindhas18-Apr-07 0:06
memberjustindhas18-Apr-07 0:06 
GeneralRe: Problems regarding Unsigned ActiveXControl Pin
Mohamed Ashraf19-Apr-07 3:01
memberMohamed Ashraf19-Apr-07 3:01 
GeneralPass arguements from web to windows [modified] Pin
justindhas17-Dec-06 19:00
memberjustindhas17-Dec-06 19:00 
GeneralInvoking Exe from web Pin
justindhas10-Dec-06 23:11
memberjustindhas10-Dec-06 23:11 
GeneralRe: Invoking Exe from web Pin
Mohamed Ashraf11-Dec-06 2:08
memberMohamed Ashraf11-Dec-06 2:08 
GeneralRe: Invoking Exe from web Pin
justindhas11-Dec-06 16:48
memberjustindhas11-Dec-06 16:48 
GeneralRe: Invoking Exe from web Pin
justindhas12-Dec-06 18:53
memberjustindhas12-Dec-06 18:53 
GeneralRe: msjava.dll Pin
Anonymous13-Oct-05 11:06
sussAnonymous13-Oct-05 11:06 
GeneralRe: msjava.dll Pin
Mohamed Ashraf14-Oct-05 21:04
memberMohamed Ashraf14-Oct-05 21:04 
GeneralRe: msjava.dll Pin
Mingsong Yin17-Oct-05 5:44
memberMingsong Yin17-Oct-05 5:44 
GeneralRe: msjava.dll Pin
Anonymous17-Oct-05 20:37
sussAnonymous17-Oct-05 20:37 
GeneralCom Package Pin
rjtrues18-May-05 7:18
memberrjtrues18-May-05 7:18 
GeneralRe: Com Package Pin
Mohamed Ashraf13-Jun-05 17:45
memberMohamed Ashraf13-Jun-05 17:45 
GeneralRe: Com Package Pin
SignedApplet1-Aug-07 0:14
memberSignedApplet1-Aug-07 0:14 
GeneralFile not found Pin
Fabrizio Brozzi13-Jan-05 22:47
sussFabrizio Brozzi13-Jan-05 22:47 
GeneralRe: File not found Pin
Anonymous14-Jan-05 0:54
sussAnonymous14-Jan-05 0:54 
GeneralRe: File not found Pin
Anonymous16-Jan-05 14:13
sussAnonymous16-Jan-05 14:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01-2016 | 2.8.180318.3 | Last Updated 1 Sep 2004
Article Copyright 2004 by Ashraf Mohamed
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid