Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
禁用Java小程序保护_Java_Applet_Serial Port_Code Access Security - Fatal编程技术网

禁用Java小程序保护

禁用Java小程序保护,java,applet,serial-port,code-access-security,Java,Applet,Serial Port,Code Access Security,我正在为我的在线预订系统构建一个小程序。工作人员可以在我的系统后端添加资金和进行交易。他们通过一个安全的网站与系统通信。当他们进行交易时,要求他们输入8个字符的个人代码。我想建立一个小程序,读取RFID芯片从读卡器我已经有 读卡器通过USB连接到计算机,Windows将此USB重定向到COM端口 我已经能够构建一个Java类,当我用以下代码扫描一个时,它读取芯片的内容: package model; import java.io.IOException; import java.io.Inpu

我正在为我的在线预订系统构建一个小程序。工作人员可以在我的系统后端添加资金和进行交易。他们通过一个安全的网站与系统通信。当他们进行交易时,要求他们输入8个字符的个人代码。我想建立一个小程序,读取RFID芯片从读卡器我已经有

读卡器通过USB连接到计算机,Windows将此USB重定向到COM端口

我已经能够构建一个Java类,当我用以下代码扫描一个时,它读取芯片的内容:

package model;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Random;
import java.util.TooManyListenersException;

import javax.comm.CommPortIdentifier;
import javax.comm.PortInUseException;
import javax.comm.SerialPort;
import javax.comm.SerialPortEvent;
import javax.comm.SerialPortEventListener;
import javax.comm.UnsupportedCommOperationException;

import view.Program;

public class Reader implements Runnable, SerialPortEventListener {
private Program program;
CommPortIdentifier portId;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;

public Reader (Program program, CommPortIdentifier portId) {
    System.out.println("");

    this.program = program;

    this.portId = portId;

    try {
        serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
    } catch (PortInUseException e) {
        e.printStackTrace();
    }
    try {
        inputStream = serialPort.getInputStream();
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        serialPort.addEventListener(this);
    } catch (TooManyListenersException e) {
        e.printStackTrace();
    }
    serialPort.notifyOnDataAvailable(true);
    try {
        serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
                SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    } catch (UnsupportedCommOperationException e) {
        e.printStackTrace();
    }
    readThread = new Thread(this);
    readThread.start();
}


@Override
public void run() {
    try {
        Thread.sleep(20000);
    } catch (InterruptedException e) {
        System.out.println(e);
    }
}

@Override
public void serialEvent(SerialPortEvent event) {
    switch (event.getEventType()) {
    case SerialPortEvent.BI:
    case SerialPortEvent.OE:
    case SerialPortEvent.FE:
    case SerialPortEvent.PE:
    case SerialPortEvent.CD:
        System.out.println("Carrier detected;");
        break;
    case SerialPortEvent.CTS:
    case SerialPortEvent.DSR:
    case SerialPortEvent.RI:
    case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
        System.out.println("Output buffer empty;");
        break;
    case SerialPortEvent.DATA_AVAILABLE:
        try {
            Random ran = new Random();
            int random = ran.nextInt();
            while (inputStream.available() > 0) {
                //System.out.println("Data available: " + inputStream.read());

                //int inputByte = inputStream.read();
                //byte inputByte2 = (byte) inputByte;


                System.out.println("Random " + random + " en resultaat " + Integer.toString(inputStream.read()));
                String id = Integer.toString(inputStream.read());
                program.setId(id);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        break;
    }

}

}
到目前为止还不错。但当我在小程序中实现该类时,会出现异常:

Caught java.lang.NullPointerException: name can't be null while loading driver com.sun.comm.Win32Driver
我搜索了internet,发现我可以通过将以下内容添加到小程序的初始代码中,使其在Eclipse中工作:

System.setSecurityManager(null);
但是,当我在浏览器中运行小程序时,会收到以下通知:


无法找到此问题的解决方案。

您应该修复原始异常。堆栈跟踪是什么?看看这个问题: