I am currently trying to turn the NetBeans JC emulator into something, which I can feed with APDUs from external sources. I know, that NetBeans just uses the apdutool, the reference implementation and a couple of other programs from the JCC sdk, but it seems to build a very special environment for their execution and it was not possible to address the reference implementation from an own program on the local port it is running on. Has anyone here ever tried to do something similar and can provide useful hints? Would be very grateful, since it is a real pain. My current approach is to make an external call to the apdutool and modify the script passed to it. The problem, which I am facing, is that the call fails and says it cannot find the Main class of the apdutool. It is in the tools.jar file (JCC_LOC/lib/tools.jar), but adding that jar to the classpath did not help for whatever reason. I assume, that I will have to set an other environment variable or something like that.
What I am trying at the moment:
I created a modified version of the apdutool.bat, which directly passes the location of the JCC in the JC_CONNECTED_HOME variable, so that should not be the problem (regular uses %~dp0):
#add tools to classpath
"%JAVA_HOME%\bin\java" -Djc.home=%JC_CONNECTED_HOME% -classpath %JC_CLASSPATH% com.sun.javacard.apdutool.Main %*
I verified, that tools.jar contains the necessary class:
but the call fails saying, that "com.sun.javacard.apdutool.Main" cannot be found.
Problem was a whitespace.
External access to the card is possible via the apdutool. You can call it from any other program or script, if you specify the correct command line. In Windows that means you will probably have to do a "cmx.exe -c " and pass the !!!full command!!! e.g. "apdutool -p 9026 apdu.scr" to cmd as string. It is important, that you pass the full command, because cmd.exe -c takes only one argument, which is a String. Based on that you can write a proxy.
Edited by: mdorner on 31.01.2013 06:48