【问题标题】:How to run Java Card Connected Edition Web samples on Eclipse?如何在 Eclipse 上运行 Java Card Connected Edition Web 示例?
【发布时间】:2015-12-04 03:21:40
【问题描述】:

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

所有示例都必须在 NetBeans IDE 中运行。他们不能从 此版本的开发工具包中的命令行。

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

【问题讨论】:

  • 你看过eclipse-jcde.sourceforge.netEclipseJCDE吗?
  • 据我所知是经典版。不适用于 servlet。
  • 你检查过the plugin provided by Oracle吗?它还写着“经典版”,但我会试一试。
  • 是的,我也检查过了。我无法让它与 Connected Edition 一起使用。

标签: java eclipse netbeans eclipse-plugin javacard


【解决方案1】:

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

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

hth,阿迪姆

【讨论】:

  • 我尝试使用哪个端口并不重要。同样的错误。据我所知,Connected Edition Dev。 Kit 仅适用于 Windows。相同的代码在 NetBeans 上运行良好,即使在防火墙关闭时也会在 Eclipse 上报错。
  • 那么当 Eclipse 启动并运行时,netstat -a 命令列出了什么?可能有助于重复启动和运行 NetBeans,然后比较两个 netstat -a 输出...当然,在启动 NetBeans 之前关闭 Eclipse。
  • 我在您的堆栈跟踪中注意到的其他内容...您是否在调试模式下运行它...我看到了 DebugUIPlugin?因为调试器将打开一个端口以允许您单步执行代码。您是否尝试过仅使用运行配置(无调试器)?
  • 不是调试模式。设备启动。但它在我使用的每个字符串上都给了我“不支持的字符串类型常量”(例如response.setContentType("text/html");)。所以,这个设备在 Eclipse 上似乎只适用于 Classic Edition。也许还有其他方法可以设置默认设备以使用 Connected Edition。或者这可能无法在 Eclipse 上运行。也许我需要联系 Oracle 以获取更多信息。
  • 端口已打开。但是项目没有部署。浏览器无法加载页面。
猜你喜欢
  • 2018-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
  • 2019-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多