我做了一個運行記事本小java代碼:java.lang.reflect.invocationtargetexception在瀏覽器
import java.io.IOException;
public class pad {
public static void main(String[] args) throws IOException, InterruptedException {
execute();
}
private static void execute() throws IOException, InterruptedException {
Process exec = Runtime.getRuntime().exec("notepad.exe");
exec.waitFor();
}
}
代碼工作之前罰款,但建設成一個.jar文件,之後從HTML頁面中運行時它給了我一個java.lang.reflect.invocationtargetexception錯誤,這裏是html源代碼:
<applet code="pad.class"
archive="not.jar"
width=400 height=400>
</applet>
請注意,我仍然對Java,感謝您的幫助。
即使你把它作爲applet運行,它仍然可能不起作用。小程序通常是不可信的代碼源,我懷疑Java的安全管理器會允許不可信任的代碼源用'Runtime.exec'執行任何事情。 – Jeffrey