java - 如何在 Eclipse 上运行 Java Card Connected Edition Web 示例?

标签 java eclipse netbeans eclipse-plugin javacard

我下载了Java Card Connected Edition 3.0.2从 Oracle 官网下载并安装。有一些web samples在 JCDK 中。在书面文件中:

All samples must be run from within the NetBeans IDE. They cannot be run from the command line in this release of the development kit.

Samples 可以正确地与 NetBeans IDE 配合使用。我可以导入它们并在 Java Card 平台上运行。

但我想在 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 时都会给出“不支持的字符串类型常量”。 代码示例:

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 上运行。

最佳答案

忘记中间的所有复杂软件。仅查看错误消息,您的 localhost 上似乎端口 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 denied”时,这意味着 java 试图在端口(本例中为 9025)上创建一个套接字,但无法获取端口号可能是因为阻塞(如防火墙)或不可用(其他东西正在使用端口 9025)。

在 windows 或 *nix 上,您通常可以使用 netstat 命令查看正在使用的端口。

hth,阿迪姆

关于java - 如何在 Eclipse 上运行 Java Card Connected Edition Web 示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32457822/

相关文章:

java - Spring boot devtools 和 ActiveJDBC 集成

java - 如何使用eclipse将数据插入Google Cloud mysql数据库

c++ - 使用 NetBeans [C++] 制作安装程序

java - 取消注释 Netbeans 中的代码块

java - log4j 在 Netbeans 中使用不正确的属性文件

java - 重新定位 Jtable 列标题

java - 在本地网站 (HTML) 上打开我的 Java 应用程序

java.lang.ClassNotFoundException : org. springframework.web.servlet.DispatcherServlet 谷歌应用引擎

java - hibernate 5.2.2(实体注释)+ mysql,eclipse上的第一个示例

java - 无法完全更改 Eclipse ADT 主题配色方案