当前位置: 技术问答>java相关
!!!在线等待,Applet中启动servlet出错!
来源: 互联网 发布时间:2015-11-14
本文导语: URL url = new URL("http://localhost:8080/test"); URLConnection urlcon=url.openConnection(); 在执行上面两条语句时,总出现access denied (java.net.SocketPermission 192.168.0.9:8080 connect,resolve)。 请问我该怎么解决呢? | ...
URL url = new URL("http://localhost:8080/test");
URLConnection urlcon=url.openConnection();
在执行上面两条语句时,总出现access denied (java.net.SocketPermission 192.168.0.9:8080 connect,resolve)。
请问我该怎么解决呢?
URLConnection urlcon=url.openConnection();
在执行上面两条语句时,总出现access denied (java.net.SocketPermission 192.168.0.9:8080 connect,resolve)。
请问我该怎么解决呢?
|
modify java.policy file(under jre folder typically C:Program FilesJavaSoftJRE1.4libsecurity)
grant codeBase "http://127.0.0.1/test/myjarfile.jar" {
permission java.security.AllPermission;
};
modify the codBase string according to your environment.
grant codeBase "http://127.0.0.1/test/myjarfile.jar" {
permission java.security.AllPermission;
};
modify the codBase string according to your environment.
|
在本地搜索java.policy文件,会找到两个。
将其中内容改一下:
(注意,原来的文件要备份!)
// Standard extensions get all permissions by default
grant codeBase "file:${java.home}/lib/ext/*" {
// permission java.security.AllPermission;
};
// default permissions granted to all domains
grant {
permission java.security.AllPermission;
// Allows any thread to stop itself using the java.lang.Thread.stop()
// method that takes no argument.
// Note that this permission is granted by default only to remain
// backwards compatible.
// It is strongly recommended that you either remove this permission
// from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially unsafe.
// See "http://java.sun.com/notes" for more information.
// permission java.lang.RuntimePermission "stopThread";
// allows anyone to listen on un-privileged ports
// permission java.net.SocketPermission "localhost:1024-", "listen";
// "standard" properies that can be read by anyone
// permission java.util.PropertyPermission "java.version", "read";
// permission java.util.PropertyPermission "java.vendor", "read";
// permission java.util.PropertyPermission "java.vendor.url", "read";
// permission java.util.PropertyPermission "java.class.version", "read";
// permission java.util.PropertyPermission "os.name", "read";
// permission java.util.PropertyPermission "os.version", "read";
// permission java.util.PropertyPermission "os.arch", "read";
// permission java.util.PropertyPermission "file.separator", "read";
// permission java.util.PropertyPermission "path.separator", "read";
// permission java.util.PropertyPermission "line.separator", "read";
// permission java.util.PropertyPermission "java.specification.version", "read";
// permission java.util.PropertyPermission "java.specification.vendor", "read";
// permission java.util.PropertyPermission "java.specification.name", "read";
// permission java.util.PropertyPermission "java.vm.specification.version", "read";
// permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
// permission java.util.PropertyPermission "java.vm.specification.name", "read";
// permission java.util.PropertyPermission "java.vm.version", "read";
// permission java.util.PropertyPermission "java.vm.vendor", "read";
// permission java.util.PropertyPermission "java.vm.name", "read";
};
至于其中的意思,你慢慢去领会。
还有,就是这样很不安全的,如果这样能成功的话,你揣摩一下后
改得安全一些。
具体的可参照前面 masterz() 的回复。
将其中内容改一下:
(注意,原来的文件要备份!)
// Standard extensions get all permissions by default
grant codeBase "file:${java.home}/lib/ext/*" {
// permission java.security.AllPermission;
};
// default permissions granted to all domains
grant {
permission java.security.AllPermission;
// Allows any thread to stop itself using the java.lang.Thread.stop()
// method that takes no argument.
// Note that this permission is granted by default only to remain
// backwards compatible.
// It is strongly recommended that you either remove this permission
// from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially unsafe.
// See "http://java.sun.com/notes" for more information.
// permission java.lang.RuntimePermission "stopThread";
// allows anyone to listen on un-privileged ports
// permission java.net.SocketPermission "localhost:1024-", "listen";
// "standard" properies that can be read by anyone
// permission java.util.PropertyPermission "java.version", "read";
// permission java.util.PropertyPermission "java.vendor", "read";
// permission java.util.PropertyPermission "java.vendor.url", "read";
// permission java.util.PropertyPermission "java.class.version", "read";
// permission java.util.PropertyPermission "os.name", "read";
// permission java.util.PropertyPermission "os.version", "read";
// permission java.util.PropertyPermission "os.arch", "read";
// permission java.util.PropertyPermission "file.separator", "read";
// permission java.util.PropertyPermission "path.separator", "read";
// permission java.util.PropertyPermission "line.separator", "read";
// permission java.util.PropertyPermission "java.specification.version", "read";
// permission java.util.PropertyPermission "java.specification.vendor", "read";
// permission java.util.PropertyPermission "java.specification.name", "read";
// permission java.util.PropertyPermission "java.vm.specification.version", "read";
// permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
// permission java.util.PropertyPermission "java.vm.specification.name", "read";
// permission java.util.PropertyPermission "java.vm.version", "read";
// permission java.util.PropertyPermission "java.vm.vendor", "read";
// permission java.util.PropertyPermission "java.vm.name", "read";
};
至于其中的意思,你慢慢去领会。
还有,就是这样很不安全的,如果这样能成功的话,你揣摩一下后
改得安全一些。
具体的可参照前面 masterz() 的回复。
|
换一的端口试一试