[英]The Eclipse IDE is able to generate the javacard cap file but in command line I am encountering this error
The below error compelled me to dig into the build process of a cap file in the command line without using the IDE.下面的错误迫使我在不使用 IDE 的情况下在命令行中深入研究 cap 文件的构建过程。 So now, I can build a cap file from the command line using java/javac series of commands.
所以现在,我可以使用 java/javac 系列命令从命令行构建一个 cap 文件。 But I have this one applet which successfully created a cap file if built via eclipse IDE but I am encountering an error when i try to build in the command line.
但是我有这个小程序,如果通过 eclipse IDE 构建成功创建了一个 cap 文件,但是当我尝试在命令行中构建时遇到错误。 I am also having same error when I tried in a correctly setup gradle build settings/environment.
当我尝试正确设置 gradle 构建设置/环境时,我也遇到了同样的错误。 This is the error:
这是错误:
[ant:convert] [ INFO: ] Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
[ant:convert]
[ant:convert]
[ant:convert] warning: You did not supply export file for the previous minor version of the package
[ant:convert] [ INFO: ] conversion completed with 1 errors and 1 warnings.
[ant:convert] error: Class org/dx/tools/TestApplet, specified in -applet option, is abstract.
Take note, this is a working and tested applet in combination with other applets that uses this one.请注意,这是一个可工作且经过测试的小程序,与使用此小程序的其他小程序结合使用。 And this builds in the eclipse IDE.
这建立在 eclipse IDE 中。
Also I am able to generate the .class
file.我还能够生成
.class
文件。 The problem is during the convertion of the class file to cap
file.问题出在将 class 文件转换为
cap
文件的过程中。
Here is how it look like:这是它的样子:
package org.dx.tools;
import org.globalplatform.GPSystem;
import org.globalplatform.SecureChannel;
import javacardx.apdu.ExtendedLength;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;
import javacard.framework.APDU;
import javacard.framework.APDUException;
import javacard.framework.Applet;
import javacard.framework.AppletEvent;
public abstract class TestApplet extends Applet implements AppletEvent,
ExtendedLength {
...
}
This .cap
is one among five others.这个
.cap
是其他五个之一。 The others are not abstract, but inherits from this one.其他的不是抽象的,而是继承自这个。 Since it build in eclipse IDE, I can actually build the other cap files by taking the output of the IDE had produce.
Since it build in eclipse IDE, I can actually build the other cap files by taking the output of the IDE had produce. First, I
jar
the classes since as I said I can create the classes and feed to java
conversion command to build the other caps, and I also use the TestApplet.exp
that the IDE generated.首先,我
jar
类,因为正如我所说,我可以创建类并提供给java
转换命令来构建其他上限,我还使用了TestApplet.exp
生成的 TestApplet.exp
UPDATES: 2019/11/17 Here is the actual java
command options that is able to build from .class
to .cap
.更新:2019/11/17这是实际的
java
命令选项,可以从.class
构建到.cap
。 I took this as exactly from the Eclipse IDE conversion log.我完全从 Eclipse IDE 转换日志中得到了这个。
If an answer can confirm this is a current gradle limitation then I will accept this answer.如果答案可以确认这是当前的 gradle 限制,那么我将接受此答案。 If answer can show what is the correct gradle settings to make it work then I will accept this answer.
如果答案可以显示正确的 gradle 设置以使其正常工作,那么我将接受此答案。 Thanks.
谢谢。
This is very likely due to linking to a newer or older version of a library, while targeting a different Java Card version during your build process.这很可能是由于链接到较新或较旧版本的库,而在构建过程中针对不同的 Java 卡版本。 Note that the converter creates pre-linked code, so it expects to link against the correct versions.
请注意,转换器会创建预链接代码,因此它希望链接到正确的版本。
This is different from Java SE, where the classes can be linked at runtime and the location of methods and fields doesn't matter, as they are created during runtime.这与 Java SE 不同,其中类可以在运行时链接,方法和字段的位置无关紧要,因为它们是在运行时创建的。
I've resolved the issue by removing the applet {}
block in build.gradle
.我已经通过删除
build.gradle
中的applet {}
块解决了这个问题。 As the particular cap being built is an abstract class, it does not have an applet aid.由于正在构建的特定上限是抽象 class,因此它没有小程序辅助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.