如何将 JavaCard 包添加到 JavaCard 小程序?
How to add JavaCard packages to JavaCard applet?
我正在尝试构建一个简单的 Hello world JavaCard applet.I 我正在使用 NetBeans IDE。
我正在关注这个tutorial.
这是我的代码:
package classicapplet1;
import javacard.framework.*;
import java.rmi.Remote;
import javacard.framework.service.Dispatcher;
import javacard.framework.service.RMIService;
import javacard.framework.service.Service;
public class JavaCardApplet extends Applet {
HelloWorld hello;
Dispatcher disp;
Service svc;
public static void install(byte[] bArray, short bOffset, byte bLength) {
new JavaCardApplet();
}
private JavaCardApplet() {
// register();
hello = new HelloWorld();
svc=new RMIService((Remote) hello);
disp = new Dispatcher((short)1);
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
}
public static void install(byte[] buf, short ofs, short len){
(new JavaCardApplet()).register();
}
public void process(APDU apdu) {
//Insert your code here
disp.process(apdu);
}
}
IDE 没有在编辑器上显示任何错误或警告,但是当我尝试构建代码时:调试控制台中显示以下内容:
ant -f "C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet" run
__reset_for_debug__:
init-platform-properties:
Using JavaCard Platform Definition at C:\Users\Tera\AppData\Roaming\NetBeans.1\config\Services\Platforms\org-netbeans-api-java-Platform\javacard_default.jcplatform
Java Card Home is C:\Program Files\NetBeans 8.1\javacard\JCDK3.0.2_ConnectedEdition (Java Card Platform)
init-ri-properties:
init-device-properties:
Platform device property name is jcplatform.javacard_default.devicespath
Computed device folder path is C:\Users\Tera\AppData\Roaming\NetBeans.1\config\org-netbeans-modules-javacard\servers\javacard_default
Platform device file path property name is C:\Users\Tera\AppData\Roaming\NetBeans.1\config\org-netbeans-modules-javacard\servers\javacard_default\Default Device.jcard
Deploying to device Default Device http port 8019
init-keystore:
Keystore is C:\Program Files\NetBeans 8.1\javacard\JCDK3.0.2_ConnectedEdition/samples/keystore/a.keystore
build-dependencies:
unpack-dependencies:
compile:
Compiling 2 source files to
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\build\APPLET-INF\classes
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:11: error: package javacard.framework.service does not exist
import javacard.framework.service.Dispatcher;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:12: error: package javacard.framework.service does not exist
import javacard.framework.service.RMIService;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:13: error: package javacard.framework.service does not exist
import javacard.framework.service.Service;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:22: error: cannot find symbol
Dispatcher disp;
symbol: class Dispatcher
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:23: error: cannot find symbol
Service svc;
symbol: class Service
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:48: error: cannot find symbol
svc=new RMIService((Remote) hello);
symbol: class RMIService
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:49: error: cannot find symbol
disp = new Dispatcher((short)1);
symbol: class Dispatcher
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:50: error: cannot find symbol
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
symbol: variable Dispatcher
location: class JavaCardApplet
8 errors
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\nbproject\build-impl.xml:301: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)
注意:NetBEans IDE 安装了 JavaCard 插件。
手动将 api_classic.jar
库及其导出路径添加到项目的库中。此文件存在于此路径下:
<NetbeansInstalledDirectory>\javacard\JCDK3.0.2_ConnectedEdition\lib
初学者循序渐进:
现在,尝试重新构建它。
我正在尝试构建一个简单的 Hello world JavaCard applet.I 我正在使用 NetBeans IDE。
我正在关注这个tutorial.
这是我的代码:
package classicapplet1;
import javacard.framework.*;
import java.rmi.Remote;
import javacard.framework.service.Dispatcher;
import javacard.framework.service.RMIService;
import javacard.framework.service.Service;
public class JavaCardApplet extends Applet {
HelloWorld hello;
Dispatcher disp;
Service svc;
public static void install(byte[] bArray, short bOffset, byte bLength) {
new JavaCardApplet();
}
private JavaCardApplet() {
// register();
hello = new HelloWorld();
svc=new RMIService((Remote) hello);
disp = new Dispatcher((short)1);
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
}
public static void install(byte[] buf, short ofs, short len){
(new JavaCardApplet()).register();
}
public void process(APDU apdu) {
//Insert your code here
disp.process(apdu);
}
}
IDE 没有在编辑器上显示任何错误或警告,但是当我尝试构建代码时:调试控制台中显示以下内容:
ant -f "C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet" run
__reset_for_debug__:
init-platform-properties:
Using JavaCard Platform Definition at C:\Users\Tera\AppData\Roaming\NetBeans.1\config\Services\Platforms\org-netbeans-api-java-Platform\javacard_default.jcplatform
Java Card Home is C:\Program Files\NetBeans 8.1\javacard\JCDK3.0.2_ConnectedEdition (Java Card Platform)
init-ri-properties:
init-device-properties:
Platform device property name is jcplatform.javacard_default.devicespath
Computed device folder path is C:\Users\Tera\AppData\Roaming\NetBeans.1\config\org-netbeans-modules-javacard\servers\javacard_default
Platform device file path property name is C:\Users\Tera\AppData\Roaming\NetBeans.1\config\org-netbeans-modules-javacard\servers\javacard_default\Default Device.jcard
Deploying to device Default Device http port 8019
init-keystore:
Keystore is C:\Program Files\NetBeans 8.1\javacard\JCDK3.0.2_ConnectedEdition/samples/keystore/a.keystore
build-dependencies:
unpack-dependencies:
compile:
Compiling 2 source files to
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\build\APPLET-INF\classes
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:11: error: package javacard.framework.service does not exist
import javacard.framework.service.Dispatcher;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:12: error: package javacard.framework.service does not exist
import javacard.framework.service.RMIService;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:13: error: package javacard.framework.service does not exist
import javacard.framework.service.Service;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:22: error: cannot find symbol
Dispatcher disp;
symbol: class Dispatcher
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:23: error: cannot find symbol
Service svc;
symbol: class Service
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:48: error: cannot find symbol
svc=new RMIService((Remote) hello);
symbol: class RMIService
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:49: error: cannot find symbol
disp = new Dispatcher((short)1);
symbol: class Dispatcher
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:50: error: cannot find symbol
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
symbol: variable Dispatcher
location: class JavaCardApplet
8 errors
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\nbproject\build-impl.xml:301: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)
注意:NetBEans IDE 安装了 JavaCard 插件。
手动将 api_classic.jar
库及其导出路径添加到项目的库中。此文件存在于此路径下:
<NetbeansInstalledDirectory>\javacard\JCDK3.0.2_ConnectedEdition\lib
初学者循序渐进:
现在,尝试重新构建它。