Eclipse无法构建Java Card示例项目 [英] Eclipse fails to build Java Card sample projects

查看:153
本文介绍了Eclipse无法构建Java Card示例项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据遵循指南。这包括所有先决条件以及JCDK的3.0.5u2版本。请注意,我尝试将其安装在2台不同的计算机上(一台安装Win7,另一台安装Win10),然后在两台计算机上都重新安装了所有软件。

I have installed the new release of Java Card Platform Development Kit, according to the following guide. This includes all the prerequisites, as well as version 3.0.5u2 of JCDK. As a heads up, I tried installing this on 2 different computers (one has Win7, the other Win10) and reinstalled everything on both.

我遇到的问题是没有任何示例项目可以正确构建。例如,当我尝试构建HelloWorld示例时,会在构建控制台中打印以下文本:

The problem I'm encountering is that none of the sample projects will build properly. When I try to build the HelloWorld sample, for example, I get the following text printed in the build console:

[ INFO: ] Converter [v3.0.5]
[ INFO: ]     Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.

[ INFO: ] conversion completed with 0 errors and 0 warnings.
[ INFO: ] Converter [v3.0.5]
[ INFO: ]     Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.

[ INFO: ] conversion completed with 0 errors and 0 warnings.
Missing file containing component hashes.
usage: scriptgen [-options] -hashfile <hash file path> <cap File Path>
where options include:
-help           Print this message and exit.
-o <filename>   Output filename. default: stdout
-version        Print version number and exit.
-nobanner       Do not print banner.
-nobeginend     Suppress "CAP_BEGIN", "CAP_END" APDU commands.
-package <pkgname>   Package name.

常规控制台上这样说:

Executing "$JC_CLASSIC_HOME\bin/converter.bat" -debug -nobanner -out CAP JCA -classdir "$JC_CLASSIC_HOME\samples\classic_applets\HelloWorld\applet\bin" -d "$JC_CLASSIC_HOME\samples\classic_applets\HelloWorld\applet\deliverables" -exportpath "$JC_CLASSIC_HOME\api_export_files" -applet 0xA0:0x00:0x00:0x00:0x62:0x03:0x01:0x0C:0x01:0x01 com.sun.jcclassic.samples.helloworld.HelloWorld com.sun.jcclassic.samples.helloworld 0xA0:0x00:0x00:0x00:0x62:0x03:0x01:0x0C:0x01 1.0
Executing "$JC_CLASSIC_HOME\bin/scriptgen.bat" -package com.sun.jcclassic.samples.helloworld -o "$JC_CLASSIC_HOME\samples\classic_applets\HelloWorld\applet\apdu_scripts/cap-com.sun.jcclassic.samples.helloworld.script" "$JC_CLASSIC_HOME\samples\classic_applets\HelloWorld\applet\deliverables/com/sun/jcclassic/samples/helloworld/javacard/helloworld.cap"
java.io.FileNotFoundException: $JC_CLASSIC_HOME\samples\classic_applets\HelloWorld\applet\apdu_scripts\cap-com.sun.jcclassic.samples.helloworld.script (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    ... (stack trace)

现在,我是我不能100%确定,但是我认为当我安装3.0.5u1版时,我能够构建示例项目。

Now, I'm not 100% sure, but I think that when I had version 3.0.5u1 installed, I was able to build the sample projects.

推荐答案

似乎Java Card Classic Development Kit 3.0.5u2(jcdk)Eclipse插件的构建过程已中断。在构建Java卡小程序期间,将执行jcdk安装目录的bin子目录中的三个脚本(如果使用eclipse中的默认小程序设置):

It seems the build process of the Java Card Classic Development Kit 3.0.5u2 (jcdk) Eclipse Plugin is broken. During the build of an java card applet, three scripts located in the bin subdirectory of the jcdk installation directory are executed (if using default applet settings in eclipse):


  1. converter.bat生成导出文件* .exp

  2. converter.bat生成帽子(和jca)文件

  3. scriptgen.bat

问题是,scriptgen需要一个包含用于该applet的哈希的哈希文件。组件。如果在jcdk lib文件夹中反编译tools.jar类的com.sun.javacard.scriptgen.Main类,就会看到此内容。

The problem is, that scriptgen requires a hashfile containing hashes for the applet components. You can see this if you decompile the class com.sun.javacard.scriptgen.Main of tools.jar in jcdk lib folder.

在月食期间不会生成此哈希文件在构建过程中,scriptgen脚本都不会用相应的程序选项 -hashfile< hash-file>来调用。当前唯一的解决方法是在控制台上手动使用jcdk工具。因此,您可以在eclipse中使用console的输出,并根据需要采用它。

This hashfile is not generated during the eclipse build process, neither is the scriptgen script called with the corresponding program option "-hashfile <hash-file>". The only workaround currently is using the jcdk tools on the console manually. Therefor you can use the output of console in eclipse and adopt it for your needs.

简单测试小程序的示例输出:

Example output for a simple test applet:

Executing E:\eclipse-oxygen-64bit\JCDKit_305u2\bin/converter.bat -i -debug -out EXP -classdir G:\eclipse_javacard\workspace\TestJCDKApplet\bin -d G:\eclipse_javacard\workspace\TestJCDKApplet\deliverables -exportpath E:\eclipse-oxygen-64bit\JCDKit_305u2\\api_export_files -applet 0xD0:0x00:0x00:0x00:0x01:0x01:0x01 test.jcdk.applet.TestApplet test.jcdk.applet 0xD0:0x00:0x00:0x00:0x01:0x01 1.0
Executing E:\eclipse-oxygen-64bit\JCDKit_305u2\bin/converter.bat -i -debug -out CAP JCA -classdir G:\eclipse_javacard\workspace\TestJCDKApplet\bin -d G:\eclipse_javacard\workspace\TestJCDKApplet\deliverables -exportpath E:\eclipse-oxygen-64bit\JCDKit_305u2\\api_export_files -applet 0xD0:0x00:0x00:0x00:0x01:0x01:0x01 test.jcdk.applet.TestApplet test.jcdk.applet 0xD0:0x00:0x00:0x00:0x01:0x01 1.0
Executing E:\eclipse-oxygen-64bit\JCDKit_305u2\bin/scriptgen.bat -package test.jcdk.applet -o G:\eclipse_javacard\workspace\TestJCDKApplet\apdu_scripts/cap-test.jcdk.applet.script G:\eclipse_javacard\workspace\TestJCDKApplet\deliverables/test/jcdk/applet/javacard/applet.cap

已修改以生成所需的脚本文件(仅列出了后两个,前两个脚本不会更改):

Modified to generate the required script files (listed only the last two, first two scripts do not change):

    G:\eclipse_javacard\workspace\TestJCDKApplet>E:\eclipse-oxygen-64bit\JCDKit_305u2\bin\verifycap.bat -outfile applet.hash E:\eclipse-oxygen-64bit\JCDKit_305u2\api_export_files\java\lang\javacard\lang.exp E:\eclipse-oxygen-64bit\JCDKit_305u2\api_export_files\javacard\framework\javacard\framework.exp .\deliverables\test\jcdk\applet\javacard\applet.exp .\deliverables\test\jcdk\applet\javacard\applet.cap
[ INFO: ] Verifier [v3.0.5]
[ INFO: ]     Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.


[ INFO: ] Verifying CAP file .\deliverables\test\jcdk\applet\javacard\applet.cap
[ INFO: ] Digest for test/jcdk/applet/javacard/Header.cap               [SHA-256: 22e589e7bbb45e420c2a17d5b8abcc437c52f00ecfb15b48ed3257f87eff62f9]
[ INFO: ] Digest for test/jcdk/applet/javacard/Directory.cap            [SHA-256: bc72a8594664c9720c38afab7c87b7dda894088f53faefcac548463a4186fbe9]
[ INFO: ] Digest for test/jcdk/applet/javacard/Import.cap               [SHA-256: e58492b256b4af8d7f1860f18e57c5336e254a618c2518c987dcefb33db0a8d0]
[ INFO: ] Digest for test/jcdk/applet/javacard/ConstantPool.cap         [SHA-256: 6c5bf615cd3746d52c815e8264b910a41a94217161862a7520087799fd03098b]
[ INFO: ] Digest for test/jcdk/applet/javacard/StaticField.cap          [SHA-256: 1ec76ec50280f5d8822179bb1b268ae7c2383d9fbe4d6c2beb427090dbf53dfd]
[ INFO: ] Digest for test/jcdk/applet/javacard/RefLocation.cap          [SHA-256: b2b3f5e23eee662b8c406212d5cb291959a8eeddb92e58b9a45941c0b91388be]
[ INFO: ] Digest for test/jcdk/applet/javacard/Descriptor.cap           [SHA-256: 292e4bd46d836b8501a19a9ea92b1ec976eca1b4920bb03499236284d17be2d7]
[ INFO: ] Digest for test/jcdk/applet/javacard/Class.cap                [SHA-256: 6c68abd77e3481a00ae2462cfc8f416ae38d4d0e4b02c685145c39d30d132526]
[ INFO: ] Digest for test/jcdk/applet/javacard/Debug.cap                [SHA-256: 7341f35fee494363bb8b84e8c132399a33a0bb4d39fd9192e92be680c08019d3]
[ INFO: ] Digest for test/jcdk/applet/javacard/Method.cap               [SHA-256: 651231359c6bb65fbcb0e3a49f52cee1a682ed7e97610365b374583638757365]
[ INFO: ] Digest for test/jcdk/applet/javacard/Applet.cap               [SHA-256: e1de8850f009796b9b991757dd378353128e10d4bc6400e5bbd970516bf187f1]
[ INFO: ] Verification completed with 0 warnings and 0 errors.

(注意:您必须将路径添加到applet使用的jcdk导出文件中,这些可以通过在Java卡程序包设置中激活详细输出并在控制台输出中搜索引用的exp文件来查找。)

(Note: you have to add the path to the jcdk export files used by the applet, these you can find out by activating verbose output in the java card package settings and searching the console output for referenced exp files.)

然后,您可以使用以下命令生成安装脚本:命令:

Then at lease you can generate the install script with the command:

G:\eclipse_javacard\workspace\TestJCDKApplet>E:\eclipse-oxygen-64bit\JCDKit_305u2\bin/scriptgen.bat -package test.jcdk.applet -o 

G:\eclipse_javacard\workspace\TestJCDKApplet\apdu_scripts/cap-test.jcdk.applet.script G:\eclipse_javacard\workspace\TestJCDKApplet\deliverables/test/jcdk/applet/javacard/applet.cap -hashfile applet.hash
ScriptGen [v3.0.5]
    Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.


APDU script file for CAP file download generated.

这篇关于Eclipse无法构建Java Card示例项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆