当前位置: 技术问答>java相关
请教:关于线程的问题。
来源: 互联网 发布时间:2017-04-24
本文导语: 在applet里调用一个可执行程序,比如notepad.exe,在jbuilder下运行applet的时候通过,但是我运行该applet的html写的页面的时候,却不能调出notepad.exe,出现很多错误,请各位大侠帮忙看看,是为什么啊? 写的代码是: void...
在applet里调用一个可执行程序,比如notepad.exe,在jbuilder下运行applet的时候通过,但是我运行该applet的html写的页面的时候,却不能调出notepad.exe,出现很多错误,请各位大侠帮忙看看,是为什么啊?
写的代码是:
void mynewthread(){
//must be use a new thread.
Thread t = new Thread(new Runnable(){
public void run(){
try {
Process p = Runtime.getRuntime().exec("notepad");
p.waitFor();
System.out.println("return code: " + p.exitValue());
} catch (IOException e) {
System.err.println("IO error: " + e);
} catch (InterruptedException e1) {
System.err.println("Exception: " + e1.getMessage());
}
}
});
t.start();
}
java控制台报的信息是:
==============================================
com.ms.security.SecurityExceptionEx[Host]: java.io.IOException: bad path: E:jakarta-tomcat-3.3.1webappsROOTccuntitled1Applet1.class
at com/ms/security/permissions/FileIOPermission.check (FileIOPermission.java)
at com/ms/security/PolicyEngine.deepCheck (PolicyEngine.java)
at com/ms/security/PolicyEngine.checkPermission (PolicyEngine.java)
at com/ms/security/StandardSecurityManager.chk (StandardSecurityManager.java)
at com/ms/security/StandardSecurityManager.checkRead (StandardSecurityManager.java)
at java/io/File.isDirectory (File.java)
at sun/net/www/protocol/file/FileURLConnection.connect (FileURLConnection.java)
at sun/net/www/protocol/file/FileURLConnection.getInputStream (FileURLConnection.java)
at com/ms/vm/loader/ResourceLoader.getURLData (ResourceLoader.java)
at com/ms/vm/loader/ResourceLoader.getCodebaseRelativeData (ResourceLoader.java)
at com/ms/vm/loader/ResourceLoader.getClassData (ResourceLoader.java)
at com/ms/vm/loader/URLClassLoader.findClass (URLClassLoader.java)
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.run (AppletPanel.java)
at java/lang/Thread.run (Thread.java)
java.lang.ClassNotFoundException: untitled1.Applet1
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.run (AppletPanel.java)
at java/lang/Thread.run (Thread.java)
写的代码是:
void mynewthread(){
//must be use a new thread.
Thread t = new Thread(new Runnable(){
public void run(){
try {
Process p = Runtime.getRuntime().exec("notepad");
p.waitFor();
System.out.println("return code: " + p.exitValue());
} catch (IOException e) {
System.err.println("IO error: " + e);
} catch (InterruptedException e1) {
System.err.println("Exception: " + e1.getMessage());
}
}
});
t.start();
}
java控制台报的信息是:
==============================================
com.ms.security.SecurityExceptionEx[Host]: java.io.IOException: bad path: E:jakarta-tomcat-3.3.1webappsROOTccuntitled1Applet1.class
at com/ms/security/permissions/FileIOPermission.check (FileIOPermission.java)
at com/ms/security/PolicyEngine.deepCheck (PolicyEngine.java)
at com/ms/security/PolicyEngine.checkPermission (PolicyEngine.java)
at com/ms/security/StandardSecurityManager.chk (StandardSecurityManager.java)
at com/ms/security/StandardSecurityManager.checkRead (StandardSecurityManager.java)
at java/io/File.isDirectory (File.java)
at sun/net/www/protocol/file/FileURLConnection.connect (FileURLConnection.java)
at sun/net/www/protocol/file/FileURLConnection.getInputStream (FileURLConnection.java)
at com/ms/vm/loader/ResourceLoader.getURLData (ResourceLoader.java)
at com/ms/vm/loader/ResourceLoader.getCodebaseRelativeData (ResourceLoader.java)
at com/ms/vm/loader/ResourceLoader.getClassData (ResourceLoader.java)
at com/ms/vm/loader/URLClassLoader.findClass (URLClassLoader.java)
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.run (AppletPanel.java)
at java/lang/Thread.run (Thread.java)
java.lang.ClassNotFoundException: untitled1.Applet1
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.run (AppletPanel.java)
at java/lang/Thread.run (Thread.java)
|
不是线程的问题!
Applet不能调用本地资源,这是安全性错误!
Applet不能调用本地资源,这是安全性错误!
|
是啊 你可以使用证书