ASP.NET 페이지에서 직렬 포트 용 바이트를 보내기 위해 Java 애플릿을 사용하려고합니다. cshtml에서Java Appet java.lang.NullPointerException
나는이 오류가 Internet Explorer에서 실행 자바 스크립트
<pre><script type="text/javascript">
var attributes = {
code: 'Principal.class', archive: 'Applet.jar', width: 325, height: 325
};
var parameters = { fontSize: 16 };
var version = '1.7';
deployJava.runApplet(attributes, parameters, version);
</script></pre>
내 애플릿을 호출합니다. 교장에
java.lang.NullPointerException이을 (Principal.java:99) sun.reflect.NativeConstructorAccessorImpl.newInstance0 (기본 메서드)에서 sun.reflect.NativeConstructorAccessorImpl.newInstance (알 수없는 소스) at sun.reflect.DelegatingConstructorAccessorImpl.new 인스턴스 일에서 sun.applet.AppletPanel.createApplet (알 수없는 소스)에서 java.lang.Class.newInstance (알 수없는 소스)에서 java.lang.reflect.Constructor.newInstance (알 수없는 소스) 에서 (알 소스). java.lang.Thread.run에서 sun.applet.AppletPanel.run (알 소스)에 sun.applet.AppletPanel.runLoader (알 소스)에 plugin.AppletViewer.createApplet (알 소스) (알 소스)
내 애플릿 :
private static final long serialVersionUID = 1L;
static CommPortIdentifier portId1;
static CommPortIdentifier portId2;
InputStream inputStream;
OutputStream outputStream;
SerialPort serialPort1, serialPort2;
protected String divertCode = "10";
static String TimeStamp;
@Override
public void serialEvent(SerialPortEvent arg0) {}
public static void main (String[] args){
try {
portId1 = CommPortIdentifier.getPortIdentifier("COM11");
//portId2 = CommPortIdentifier.getPortIdentifier("COM9");
Principal reader = new Principal();
} catch (NoSuchPortException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
public Principal(){
try {
TimeStamp = new java.util.Date().toString();
serialPort1 = (SerialPort) portId1.open("Principal",2000);
// System.out.println(TimeStamp+":"+portId1.getName()+"porta aberta");
//serialPort2 = (SerialPort) portId2.open("Principal",2000);
//System.out.println(TimeStamp+":"+portId2.getName()+"porta aberta");
try {
serialPort1.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort1.setDTR(false);
serialPort1.setRTS(false);
try {
outputStream = serialPort1.getOutputStream();
String texto = "Testando envio \n";
byte[] envio = texto.getBytes();
outputStream.write(envio);
} catch (IOException e) {
e.printStackTrace();
}
} catch (UnsupportedCommOperationException e) {
e.printStackTrace();
}
} catch (PortInUseException e) {
}
}
내 URL은 이미 신뢰할 수있는 자바에 나열되어 있으며 내 애플릿은 자체 인증되었습니다. 누군가 나를 도울 수 있습니까?
는 보안을 애플릿 관련하는 단계; 애플릿 코드 내부의 로직에 문제가 있습니다. 더 많은 정보가 없으면 어떤 도움도 제공 할 수 없습니다. –
오류는 HTML이 아닌 애플릿에 있음이 분명합니다. 'Principal.java' _do_의'99' 행은 무엇입니까? –
내 애플릿이 작동합니다. 어쨌든 asp.net 응용 프로그램 –