简体   繁体   English

为什么Eclipse在尝试转换applet时会返回错误,而NetBeans却没有?

[英]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 SDKEclipse-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.

相关问题 尝试在浏览器上打开applet时出现错误事件 - Error Event when trying to open applet on a browser 为什么 netbeans 中的 Applet 这个词是 Striken? - Why the word Applet is Striken in netbeans? 尝试在NetBeans中运行向导模块时出错 - Error while trying to run a wizard module in netbeans 尝试从服务器获取小程序时出现RMI错误 - RMI error while trying to get an applet from the server gwt requestbuilder尝试使用Eclipse Jetty访问xml文件时返回404 NOT_FOUND错误 - gwt requestbuilder returns 404 NOT_FOUND error while trying to access xml-file with eclipse jetty 尝试运行Java项目时出现Netbeans错误 - Netbeans error when trying to run java project 为什么这段代码在Netbeans中抛出ClassCastException而在Eclipse中运行良好 - Why is this code throwing a ClassCastException in netbeans while its runing fine in eclipse 尝试更新Eclipse时出错 - Error when trying to update Eclipse 尝试在 Netbeans 上运行 JavaFx 项目时,为什么我在 MacOS 上不断收到此 SIGBUS 错误代码? - Why do I keep getting this SIGBUS error code on my MacOS when trying to run a JavaFx Project on Netbeans? 开始:NetBeans IDE 8.0中的Applet未初始化错误 - Start: Applet not initialized error in NetBeans IDE 8.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM