Java Reference
In-Depth Information
L ISTING 5.5 Continued
apdu.setOutgoingLength( (short) (3) );
// output header
apdu.sendBytes( (short)0, (short) 3);
// writes data
apdu.sendBytesLong( bytes, (short) 0, (short) 0 );
}
}
Listing 5.6 shows the commands to compile it. Note the use of the -g option, which is needed
because the converter tool determines the local variable types by checking the
LocalVariableTable attribute within the .class file. Such an attribute is generated only if the
-g option is used.
L ISTING 5.6 Compiling the CardTest Applet
set JC_HOME=...
javac -g -classpath % JC_HOME%\lib\api21.jar CardTest.java
Then, when the CardTest.class file is produced, we need to transform it in a CAP file. We
use the converter utility, together with an optional input file (called CardTest.opt in the exam-
ple) that declares all input options for the conversion process. Such a file is shown in Listing
5.8.
L ISTING 5.7 Compiling the CardTest Applet
set _CLASSES=%JC_HOME%\lib\apduio.jar; . . . ;%JC_HOME%\lib\
[ic:ccc]api21.jar;%JC_HOME%\lib\capdump.jar;
xcopy /s %JC_HOME%\api21_export_files\*.* exp\
java -classpath %_CLASSES% com.sun.javacard.converter.Converter
[ic:ccc]-config CardTest.opt
At line 1 of Listing 5.7, for brevity, we omitted to mention all the JAR libraries found in the
/lib directory of the installed Java Card Development Kit. At line 2 of Listing 5.7, we copy
the export files for the standard libraries in a temporary directory, from where we will access
them from the -exportpath option in Listing 5.8. We said that EXP files are much like C
header files, needed for linking and other utility purposes (in Listing 5.9 is shown an example
of such a file converted in plain text).
Search WWH ::




Custom Search