我从Oracle官网下载Java Card Connected Edition 3.0.2并安装。在JCDK中有一些web示例。在文档中写:
所有示例必须在NetBeans IDE中运行。他们无法逃避这个开发工具包版本中的命令行。
Samples与NetBeans IDE正确工作。我可以导入它们并在Java Card Platform上运行。
但是我想在Eclipse IDE上使用这个示例。在Eclipse中作为Java Card SDK路径,我显示了Java Card Connected的主路径。然后创建新设备并尝试启动它[例如CardHolderApp]。但是Eclipse给出:
ApduTool thread exited
User input thread exited
APDU|ApduTool [v3.0.2]
APDU| Copyright (c) 2009 Sun Microsystems, Inc.
APDU| All rights reserved.
APDU| Use is subject to license terms.
APDU|Opening connection to localhost on port 9025.
APDU|Connected.
APDU|java.net.ConnectException: Connection refused: connect
ApduTool process finished with code: 1
. log文件:
!ENTRY org.eclipse.core.jobs 4 2 2015-09-08 01:39:17.142
!MESSAGE An internal error occurred during: "Launching CardHolderApp".
!STACK 0
java.lang.RuntimeException: Cannot start device. Please see the log.
at com.oracle.javacard.jcdk.launch.runconfiguration.AppletRunConfigurationDelegate.launch(AppletRunConfigurationDelegate.java:79)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
是否可以在Eclipse IDE中运行Java Card Connected Web项目?
更新:
设备启动成功。但是项目没有部署。它在每次使用String时给出"不支持的String类型常量"。代码示例:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html"); // unsupported String type constant
PrintWriter out = response.getWriter();
RequestDispatcher dispatcher = null;
dispatcher = request.getRequestDispatcher("/WEB-INF/header.i");//unsupported String type constant
response.sendRedirect(response.encodeRedirectURL("http://www.sun.com"));//unsupported String type constant
dispatcher.include(request, response);
dispatcher.include(request, response);
}
经典版不支持字符串。但它必须在Connected Edition上运行
忘记中间所有复杂的软件。查看错误消息,看起来端口9025在本地主机上未打开或不可用:
APDU|Opening connection to localhost on port 9025.
APDU|Connected.
APDU|java.net.ConnectException: Connection refused: connect
ApduTool process finished with code: 1
文本[java.net.ConnectException: Connection refused: connect],每次我看到"Connection refused",这意味着java试图在端口上创建一个套接字(在这种情况下为9025),并且由于阻塞(如防火墙)或不可用(其他东西正在使用端口9025)而无法获得端口号。
在windows或*nix上,您通常可以使用netstat命令查看正在使用的端口。
hth, adym