[英]Why Eclipse returns an error when trying to convert an applet, while NetBeans not?
Below, you see a Java Card program that acts as a 8 byte random number generator : 下面,您将看到一个充当8字节随机数生成器的Java Card程序:
package randGen;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
import javacard.framework.JCSystem;
import javacard.framework.Util;
import javacard.security.RandomData;
public class RandGen extends Applet {
byte[] generatedArray;
RandomData randData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
private RandGen() {
generatedArray = JCSystem.makeTransientByteArray((short)8, JCSystem.CLEAR_ON_DESELECT);
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new RandGen().register();
}
public void process(APDU arg0) throws ISOException {
byte[] byffer = arg0.getBuffer();
byte[] generatedRandom = MyGenerator(arg0);
Util.arrayCopyNonAtomic(generatedRandom, (short) 0, byffer, (short) 0,
(short) generatedRandom.length);
arg0.setOutgoingAndSend((short) 0, (short) generatedRandom.length);
}
public byte[] MyGenerator(APDU apdu) {
randData.generateData(generatedArray, (short) 0, (short) 8);
return generatedArray;
}
}
This program converts to .cap file successfully in NetBeans IDE, but when I wanted to do the same operation with the Eclipse IDE, it returns the below error in respond of my request for conversion the applet : 此程序在NetBeans IDE中成功转换为.cap文件,但是当我想要与Eclipse IDE执行相同的操作时,它会返回以下错误以响应我的转换applet的请求:
error: randGen: empty package.
错误:randGen:空包。
I added an image also : (As you see there is not error in the code, but the project directory marked with a red times mark as a sign of an error) 我还添加了一个图像:(如您所见,代码中没有错误,但项目目录标有红色时间标记作为错误的标志)
Update : I used Java Card 2.2.2 SDK and Eclipse-JCDE 0.2 plugin to convert my program to cap files in Eclipse. 更新:我使用Java Card 2.2.2 SDK和Eclipse-JCDE 0.2插件将我的程序转换为Eclipse中的cap文件。
Any idea? 任何的想法?
Sometimes Eclipse fails to completely delete the .class files or .cap files on Windows machines, usually due to a program (eg McAfee or another virus scanner) locking files. 有时Eclipse无法完全删除Windows机器上的.class文件或.cap文件,这通常是由于程序(例如McAfee或其他病毒扫描程序)锁定文件。 In that case not all files will be deleted.
在这种情况下,不会删除所有文件。 In that case the right builders may not get triggered and you will get weird failures.
在这种情况下,正确的构建器可能不会被触发,您将得到奇怪的故障。
Those kind of errors are of course horrible to detect. 这些错误当然是可怕的。 Instead, if something fails uncontrollably, be sure to clean your build so Eclipse can retry.
相反,如果某些事情无法控制地失败,请务必清理您的构建,以便Eclipse可以重试。 If you've changed code, first refresh, then clean (and possibly, refresh again).
如果您更改了代码,请首先刷新,然后清理(并可能再次刷新)。 Anything to get the project state synced with the actual state on disk really.
任何让项目状态真正与磁盘上的实际状态同步的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.