title: JCWDE simulator run: exception from the invoked install() method
body: <p>I am trying to run a jwcde simulation with a hello world applet. I use JC221.</p>
  
  <p>This is the applet:</p>
  
  <pre><code>package hello;
  
  
  
  import javacard.framework.APDU;
  
  import javacard.framework.Applet;
  
  import javacard.framework.ISO7816;
  
  import javacard.framework.ISOException;
  
  import javacard.framework.Util;
  
  
  
  public class HelloWorldApplet extends Applet {
  
           private static final byte[] helloWorld = {(byte)'H',(byte)'e',(byte)'l',(byte)'l',(byte)'o',(byte)' ',(byte)'W',(byte)'o',(byte)'r',(byte)'l',(byte)'d',};
  
  
  
           private static final byte HW_CLA = (byte)0x80;
  
           private static final byte HW_INS = (byte)0x00;
  
  
  
           public static void install(byte[] bArray, short bOffset, byte bLength) {
  
               new HelloWorldApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
  
           }
  
  
  
           public void process(APDU apdu) {
  
  
  
               if (selectingApplet()) {
  
               return;
  
           }
  
  
  
           byte[] buffer = apdu.getBuffer();
  
           byte CLA = (byte) (buffer[ISO7816.OFFSET_CLA] &amp; 0xFF);
  
           byte INS = (byte) (buffer[ISO7816.OFFSET_INS] &amp; 0xFF);
  
  
  
           if (CLA != HW_CLA)
  
          {
  
              ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
  
          }
  
  
  
            switch ( INS ) {
  
               case HW_INS:
  
                 getHelloWorld( apdu );
  
                 break;
  
              default:
  
                 ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
  
           }
  
     }
  
  
  
    private void getHelloWorld( APDU apdu)
  
    {
  
        byte[] buffer = apdu.getBuffer();
  
        short length = (short) helloWorld.length;
  
  
  
        Util.arrayCopyNonAtomic(helloWorld, (short)0, buffer, (short)0, (short) length);
  
  
  
        apdu.setOutgoingAndSend((short)0, length);
  
    }
  
  }
  </code></pre>
  
  <p>I managed to compile it with this command:</p>
  
  <pre><code>javac -g -d hello -classpath “.;%JC_HOME%\lib\api.jar;%JC_HOME%\lib\javacardframework.jar” HelloWorldApplet.java
  </code></pre>
  
  <p>And I checked that the compiled class file is on the path.</p>
  
  <p>This is the jcwde.app file that jcwde uses:</p>
  
  <pre><code>//+
  
  // Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
  
  // SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  
  //-
  
  
  
  //+
  
  // Workfile:@(#)jcwde.app    1.4
  
  // Version:1.4
  
  // Date:07/16/03
  
  //-
  
  
  
  // applet                                        AID
  
  com.sun.javacard.installer.InstallerApplet       0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0x8:0x1
  
  com.sun.javacard.samples.JavaPurse.JavaPurse     0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x2:0x1
  
  com.sun.javacard.samples.JavaLoyalty.JavaLoyalty 0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x5:0x1
  
  com.sun.javacard.samples.wallet.Wallet           0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x6:0x1
  
  hello.HelloWorldApplet                           0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x08:0x09:0x00:0x01 
  </code></pre>
  
  <p>I start jcwde with this command in a command line window (Windows7):</p>
  
  <pre><code>jcwde jcwde.app
  </code></pre>
  
  <p>Then I start a new command line window and start apdutool there:</p>
  
  <pre><code>apdutool -nobanner -noatr HelloWorldApplet.scr &gt; hello.scr.jcwde.out
  </code></pre>
  
  <p>Here is the .scr script file:
      powerup;</p>
  
  <pre><code>// Select the installer applet
  0x00 0xA4 0x04 0x00 0x09 0xa0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F;
  // 90 00 = SW_NO_ERROR
  
  // create Applet
  0x80 0xB8 0x00 0x00 0x0d 0x0b 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x01 0x00 0x7F;
  
  // Select Applet
  0x00 0xa4 0x04 0x00 0x0b 0x01 0x02 0x03 0x04 0x05 0x6 0x07 0x08 0x09 0x00 0x01 0x7F;
  
  // Send APDU command to get a Hello World message
  0x80 0x00 0x00 0x00 0x00 0x00;
  
  powerdown;
  </code></pre>
  
  <p>And here is the result (from the jcwde command window):</p>
  
  <pre><code>D:\jc221\samples\src\demo\jcwde&gt;jcwde jcwde.app
  
  Java Card 2.2.1 Workstation Development Environment, Version 1.3
  
  Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
  
  jcwde is listening for T=0 Apdu's on TCP/IP port 9á025.
  
  Exception from the invoked install() method:public static void hello.HelloWorldApplet.install(byte[],short,byte)
  
  jcwde exiting on receipt of power down command.
  
  
  
  D:\jc221\samples\src\demo\jcwde&gt;
  </code></pre>
  
  <p>And this is the result in the hello.scr.jcwde.out file:</p>
  
  <pre><code>CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
  
  CLA: 80, INS: b0, P1: 00, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
  
  CLA: 80, INS: b8, P1: 00, P2: 00, Lc: 0d, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 01, 00, Le: 00, SW1: 64, SW2: 44
  
  CLA: 80, INS: ba, P1: 00, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
  
  CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 01, Le: 00, SW1: 6d, SW2: 00
  
  CLA: 80, INS: 00, P1: 00, P2: 00, Lc: 00, Le: 00, SW1: 6d, SW2: 00
  </code></pre>
  
  <p>So the question is why does it throw exception: Exception from the invoked install() method:public static void hello.HelloWorldApplet.install(byte[],short,byte)</p>
  
  <p>And why is the result SW at the third line SW1:64 SW2:44 and not 90 00 as it should be?</p>