C H A P T E R   6

Compiling Source Code

This chapter describes the use of the Java Card 3 platform Compiler tool ( javacardc.bat ) in compiling the source code of applications outside of an IDE.

See Chapter 3 to better understand the role and relationship between the Compiler tool and the other Development Kit tools used in developing applications for the Java Card 3 platform.


Running the Compiler Tool from the Command Line

The Compiler tool provides a wrapper for javac (the JDK compiler) and includes an annotation processor for the Java Card 3 platform to check for unsupported language features, such as the use of float and double .

Compiler Tool Options

In addition to Java Card 3 platform specific options, all standard javac options for JDK 1.6 can be used:

TABLE 6-1 Compiler Tool Options

Option

Description

-g 

Generate all debugging info

-g:none 

Generate no debugging info

-g:{lines,vars,source} 

Generate only some debugging info

-nowarn

Generate no warnings

-verbose

Output messages about what the compiler is doing

-deprecation

Output source locations where deprecated APIs are used

-classpath path

Specify where to find user class files and annotation processors

-cp path

Specify where to find user class files and annotation processors.

-sourcepath path

Specify where to find input source files.

-bootclasspath path

Override location of bootstrap class files.

-extdirs dirs

Override location of installed extensions.

-endorseddirs dirs

Override location of endorsed standards path.

-proc:{none,only} 

Control whether annotation processing and/or compilation is done.

-processor class1
[,class2
,class3
...]

Names of the annotation processors to run; bypasses default discovery process.

-processorpath path

Specify where to find annotation processors.

-d directory

Specify where to place generated class files.

-s directory

Specify where to place generated source files.

-implicit:{none,class}

Specify whether or not to generate class files for implicitly referenced files.

-encoding encoding

Specify character encoding used by source files.

-source release

Provide source compatibility with specified release.

-target release

Generate class files for specific VM version.

-version

Version information.

-help

Print a synopsis of standard options.

-Akey[=value]

Options to pass to annotation processors.

-X

Print a synopsis of nonstandard options.

-Jflag

Pass flag directly to the runtime system.

Format

The following is an example of the Compiler tool command format:

javacardc.bat [ options ] [ sourcefiles ] [ @list_files ]

In the format example:

Examples

A .java file named UsesFloat.java contains the following source:

public class UsesFloat {
		float f = 0;
	}

It uses float , which is not supported by the Java Card 3 platform. Compiling this file with standard javac generates a class file without any errors. However, javacardc.bat fails the compilation with an error such as the following:

C:\JCDK3.0.1_ConnectedEdition\bin>javacardc.bat UsesFloat.java 
Java Card 3.0.1 Compiler 
UsesFloat.java:2: float keyword used 
	float f = 0; 
	^ 
1 error

The bold text in the example output indicates the error message text.