Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
public:smartcard:javacardcompilation [2010-10-26 11:16] xkurpublic:research:smartcard:javacardcompilation [2016-12-01 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== JavaCard applet development ======
 +~~NOTOC~~
 +<note tip>The description in section 'JavaCard applet development with NetBeans IDE' is outdated as we now have easier option.</note>
 +
 +===== JavaCard applet development with AppletPlayground/GlobalPlatformPro/JCardSim and JCAlgTest =====
 +
 +  * Use AppletPlayground for compilation and conversion into JavaCard applet (by Martin Paljak): https://github.com/martinpaljak/AppletPlayground
 +  * Use GlobalPlatformPro for upload of converted applets onto real cards (by Martin Paljak): https://github.com/martinpaljak/GlobalPlatformPro
 +  * Read slides with JavaCard development tutorial (by Petr Svenda): {{:public:research:smartcard:javacard_2016.pdf|javacard.pdf}}
 +  * Use JCardSim simulator to develop even without real smart card: https://jcardsim.org
 +  * Consult JCAlgTest project for properties (supported algorithms, performance) of real smart card if you plan to buy one: https://www.fi.muni.cz/~xsvenda/jcsupport.html
 +
 +
 +----
 +
 +
 +===== (OUTDATED) JavaCard applet development with NetBeans IDE =====
 +(c) 2010-2011 by LaBAK FI MUNI (contact us at http://www.fi.muni.cz/research/laboratories/labak/)
 +
 +{{scripttemplates.zip|Download script templates}} for common smart cards.
  
-====== JavaCard applet development with NetBeans IDE ====== 
-(c) 2010 by LaBAK FI MUNI 
-{{:public:smartcard:scripttemplates.zip|Download script templates}} for common smart cards. 
 {{:public:smarthelloworld.zip|Download example project}} with standard Sun Java Card Hello World example with all configurations applied. {{:public:smarthelloworld.zip|Download example project}} with standard Sun Java Card Hello World example with all configurations applied.
 +
 +{{JavaCard_tutorial_2011.pdf | Download slides with JavaCard tutorial.}} To be used with Ubuntu VirtualBox image.
 +
 +[[https://www.youtube.com/watch?v=khgT5dwKvOo | Oracle JavaCard tutorial (2013)]]
  
 ===== Installation process ===== ===== Installation process =====
Line 11: Line 32:
   * Apache Ant 1.7 or later (http://ant.apache.org/bindownload.cgi, already included in NetBeans)   * Apache Ant 1.7 or later (http://ant.apache.org/bindownload.cgi, already included in NetBeans)
   * GPShell 1.4.2 or later (http://sourceforge.net/projects/globalplatform/files/      * GPShell 1.4.2 or later (http://sourceforge.net/projects/globalplatform/files/   
-  * Java Card Development Kit 2.1.2 (http://www.oracle.com/technetwork/java/javacard/downloads/index-jsp-138488.html#devkit) +  * Java Card Development Kit 2.1.2 (http://www.oracle.com/technetwork/java/javacard/downloads/index-jsp-138488.html#devkit). NOTE: most of the current cards doesn't support JavaCard 2.2.2 therefore you cannot use JCDK 2.2.2.  
-  * Java Card Ant Tasks (binary and docs can be found in Java Card Development Kit 2.2.2, subdirectory "ant-tasks")+  * Java Card Ant Tasks (binary and docs can be found in Java Card Development Kit 2.2.2, subdirectory "ant-tasks"). Note: Java card Ant Tasks are not included in JCDK 2.1.2, therefore you have to copy them from JCDK 2.2.2 - but converter must be from JCDK 2.1.2 (unless your card supports JC 2.2.2.)
  
   - Install NetBeans   - Install NetBeans
Line 20: Line 41:
   - Create new Java project in NetBeans (File->New Project->Java->Java application)   - Create new Java project in NetBeans (File->New Project->Java->Java application)
   - Create a "lib" directory in the project root folder and copy Java Card Ant Tasks "jctasks.jar" into this directory.   - Create a "lib" directory in the project root folder and copy Java Card Ant Tasks "jctasks.jar" into this directory.
-  - Set configuration parameters in "nbproject/project.properties" +  - Set configuration parameters in "nbproject/project.properties" (file in your project directory)
      * jc.home     - path to Java Card Development Kit      * jc.home     - path to Java Card Development Kit
-     * jc.export_files      - path to Java Card export files (for verifier), usually ${jc.home}\\api_export_files+     * jc.export_files      - path to Java Card export files (for verifier), usually ${jc.home}\\api_export_files  (NOTE: JC SDK 2.1.2 has this folder named api21_export_files)
      * gpshell.home     - path to GPShell       * gpshell.home     - path to GPShell 
      * gpshell.cmd     - path to GPShell executable      * gpshell.cmd     - path to GPShell executable
Line 211: Line 232:
   * When compilation is done (compiled files are in build/classes/), task "convert" is executed and performs conversion and verification. Converted file can be found in build\classes\com\sun\javacard\samples\HelloWorld\javacard. This action can be configured in task "convert" in build.xml.    * When compilation is done (compiled files are in build/classes/), task "convert" is executed and performs conversion and verification. Converted file can be found in build\classes\com\sun\javacard\samples\HelloWorld\javacard. This action can be configured in task "convert" in build.xml. 
   * Testing executes script "scripts/helloInstallGP211_JCOP41_cap.txt" in GPShell and tries to install HelloWorld on compatible Java Card. This action can be configured in task "run-script" in build.xml.    * Testing executes script "scripts/helloInstallGP211_JCOP41_cap.txt" in GPShell and tries to install HelloWorld on compatible Java Card. This action can be configured in task "run-script" in build.xml. 
 +
 +===== Troubleshooting ===== 
 +
 +  * Problem: Compilation fails with error: cannot find symbol XY (e.g., symbol: variable KeyAgreement)
 +    * Correct JavaCard SDK was not added to libraries.
 +    * If you get error for all JavaCard classes, then add library for your target card (e.g., 2.2.1)
 +    * if you get this error only for few classes (but not all), then you are using JC SDK without supprt for this classes (e.g., KeyAgreement, Checksum, MEMORY_TYPE_PERSISTENT... are not present in 2.1.2, but are present in 2.2.1)
 +
 +  * Problem: Convert fails with: Error: Could not find or load main class com.sun.javacard.converter.Converter
 +    * Compilation was successful, but Converter was not found. Check if your //jc.home// path is correctly set in nbproject\project.properties file. Note that you must use double \ in path (e.g., d:\\Apps\\JavaCardSDK2.2.2)