### Example ant-javacard Build Output
Source: https://github.com/martinpaljak/ant-javacard/blob/next/README.md
This is an example of the console output when the ant-javacard task is executed, showing the SDKs being used, package names, generated applet AIDs, and the final CAP file location.
```text
target:
[cap] INFO: using JavaCard 3.0.5 SDK in sdks/jc305u4_kit
[cap] INFO: targeting JavaCard 2.2.2 SDK in sdks/jc222_kit
[cap] Setting package name to testapplets.empty
[cap] INFO: generated applet AID: A000000617008E5CDAAE01 for testapplets.empty.Empty
[cap] Building CAP with 1 applet from package testapplets.empty (AID: A000000617008E5CDAAE)
[cap] testapplets.empty.Empty A000000617008E5CDAAE01
[compile] Compiling files from /Users/martin/projects/ant-javacard/src/testapplets/empty
[compile] Compiling 1 source file to /var/folders/gf/_m9mq9td3lz32qv1hd4r12yw0000gn/T/jccpro841338375581620546
[cap] CAP saved to /Users/martin/projects/ant-javacard/Empty_A000000617008E5CDAAE_50da91a4_2.2.2.cap
```
--------------------------------
### Download ant-javacard.jar with Ant
Source: https://github.com/martinpaljak/ant-javacard/blob/next/README.md
Use the Ant get task to download the ant-javacard.jar file. Set skipexisting to true to avoid re-downloading if the file already exists.
```xml
```
--------------------------------
### Maven Integration with `maven-antrun-plugin`
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Integrate `ant-javacard` into a Maven build by using the `maven-antrun-plugin`. This example shows how to configure the plugin to execute an Ant build file (`build.xml`) during the `package` phase.
```xml
maven-antrun-plugin
3.2.0
package
run
```
```xml
```
--------------------------------
### Configure Ant JavaCard for Modern JavaCards (JDK 17)
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Use this configuration to target modern JavaCards (3.0.4+) with JDK 17 and SDK 3.2.0. Ensure JAVA_HOME is set to your JDK 17 installation when running the build.
```xml
```
```bash
JAVA_HOME=/path/to/jdk17 ant build
```
--------------------------------
### Configure Ant JavaCard for Legacy JavaCards (JDK 11)
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Use this configuration for legacy JavaCard versions (2.2.x) with JDK 11 and SDK 3.0.5. Ensure JAVA_HOME is set to your JDK 11 installation when running the build.
```xml
```
```bash
JAVA_HOME=/path/to/jdk11 ant build
```
--------------------------------
### Configure Global SDK for CAP Builds
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Use the `` task to set a default SDK path for all nested `` elements. This ensures a consistent build environment for multiple CAP files.
```xml
```
--------------------------------
### Build a JavaCard CAP File with Detailed Configuration
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Configure the `` element for building a CAP file, specifying SDKs, source paths, output names, and various build options like export, debug, and integer handling.
```xml
```
--------------------------------
### Run Off-Card Verifier
Source: https://github.com/martinpaljak/ant-javacard/blob/next/README.md
Execute the off-card verifier with specified SDK, target SDK, CAP file, and export files. The SDK path is required, and target SDK is optional.
```bash
java -jar ant-javacard.jar []
```
--------------------------------
### Configure Javacard CAP File Build
Source: https://github.com/martinpaljak/ant-javacard/blob/next/README.md
Use the and tags to define the build process for a Java Card applet's CAP file. Specify SDK paths, source/class locations, applet details, and output configurations.
```xml
```
--------------------------------
### Create JavaCard CAP Files with Ant
Source: https://github.com/martinpaljak/ant-javacard/blob/next/README.md
Use the defined 'javacard' task to create CAP files. Specify the JavaCard Kit directory and the main applet AID. Nested 'applet' tags define individual applets within the CAP file, including their class and AID.
```xml
```
--------------------------------
### Import External Library JAR and Export Files
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Link an applet against an external JavaCard library JAR for compilation and its .exp files for the converter. The 'jar' attribute is for the classpath, and 'exps' provides the folder of .exp files.
```xml
```
--------------------------------
### Download and Define Ant JavaCard Task
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Automate the download of the ant-javacard.jar and define the 'javacard' task in your build.xml. This sets up the necessary Ant task for subsequent build steps.
```xml
```
--------------------------------
### Off-Card Verification of CAP Files
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Perform off-card verification of a CAP file against a specified Java Card SDK. You can also specify a target SDK for compatibility checks and include external export files (`.exp` or `.jar`) for verification.
```bash
java -jar ant-javacard.jar sdks/jc305u4_kit MyApplet.cap
```
```bash
java -jar ant-javacard.jar sdks/jc305u4_kit sdks/jc222_kit MyApplet.cap
```
```bash
java -jar ant-javacard.jar sdks/jc305u4_kit MyApplet.cap lib/gpapi-exps
```
--------------------------------
### Dump CAP File Metadata
Source: https://github.com/martinpaljak/ant-javacard/blob/next/README.md
Use this command to extract metadata from a built .cap file. Ensure ant-javacard.jar is in your current directory or provide its full path.
```bash
java -jar ant-javacard.jar
```
--------------------------------
### Declare Multiple Applets in a CAP File
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Declare multiple applets within a single CAP file, sharing a common package AID prefix. If an AID is omitted, it is auto-generated.
```xml
```
--------------------------------
### Load ant-javacard Task in build.xml
Source: https://github.com/martinpaljak/ant-javacard/blob/next/README.md
Define the ant-javacard task in your build.xml file by specifying the task name, classname, and the classpath pointing to the downloaded ant-javacard.jar.
```xml
```
--------------------------------
### Environment Variables for Ant-Javacard
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Configure Ant-Javacard behavior using environment variables. These include specifying the Java Card SDK home (`JC_HOME`), the JDK home (`JAVA_HOME`), a temporary directory for build files (`ANT_JAVACARD_TMP`), and enabling debug logging (`ANT_JAVACARD_DEBUG`).
```bash
# Point to the JavaCard SDK to use when jckit is not set in build.xml
export JC_HOME=/path/to/jc305u4_kit
# Point to a specific JDK (critical for SDK/JDK compatibility)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
# Keep temporary build files for debugging (not cleaned up after build)
export ANT_JAVACARD_TMP=/tmp/jc-debug
# Enable verbose debug logging from ant-javacard
export ANT_JAVACARD_DEBUG=1
# Then run ant normally
ant build
```
--------------------------------
### Customize CAP Output File Name with Variables
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Customize the CAP file name using a template string with substitution variables. The default template is `%n_%a_%h_%j_%J.cap`.
```xml
```
--------------------------------
### Select Specific Source Files with Nested Sources
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Use nested `` elements to define per-directory include/exclude patterns for fine-grained source file selection. This is mutually exclusive with the flat `sources` and `sources2` attributes on ``.
```xml
```
--------------------------------
### Dump CAP File Metadata
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Use `ant-javacard.jar` to extract and display human-readable metadata from a `.cap` file, including AIDs, version, code size, and hashes. This is useful for understanding the contents of a compiled Java Card applet package.
```bash
java -jar ant-javacard.jar MyApplet_A000000062_9a037e30_2.2.2_jdk11.cap
```
--------------------------------
### Maven Dependency for `capfile` Library
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Add the `javacard.pro` repository and include the `capfile` library as a Maven dependency. This allows independent use of CAP file parsing and Java Card SDK related classes in your tools.
```xml
javacard-pro
https://mvn.javacard.pro/maven/
com.github.martinpaljak
capfile
24.03.08
```
--------------------------------
### Cross-Compile CAP for Older Java Card Versions
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Use the `targetsdk` attribute to specify a newer SDK's converter while targeting an older Java Card platform, ensuring backward compatibility. For multi-target SDKs (3.1+), use a version string.
```xml
```
--------------------------------
### Trigger ant-javacard from Maven
Source: https://github.com/martinpaljak/ant-javacard/wiki/How-to-use-from-Maven
Configure the maven-antrun-plugin in your pom.xml to execute ant-javacard tasks during the package phase. Ensure your build.xml is correctly set up.
```xml
maven-antrun-plugin
3.2.0
package
run
```
--------------------------------
### Add Maven Repository
Source: https://github.com/martinpaljak/ant-javacard/blob/next/README.md
Configure your pom.xml to include the javacard-pro Maven repository. This allows you to use ant-javacard as a dependency in your Maven projects.
```xml
javacard-pro
https://mvn.javacard.pro/maven/
```
--------------------------------
### Rename CAP File to Standard Name
Source: https://context7.com/martinpaljak/ant-javacard/llms.txt
Rename a CAP file to adhere to a standard naming convention based on its internal metadata. The `CAP_NAME_TEMPLATE` environment variable can be used to customize the output format.
```bash
java -jar ant-javacard.jar -r MyApplet.cap
```
```bash
CAP_NAME_TEMPLATE="%n_%v_%h.cap" java -jar ant-javacard.jar -r MyApplet.cap
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.