简体   繁体   English

无法在java中获得套接字权限

[英]unable to gain socket permissions in java

private boolean permissionsGranted() {
    final SocketPermission permission = new SocketPermission(
            "239.255.255.250", "connect,accept,resolve");
    try {
        AccessController.checkPermission(permission);
        return true;
    } catch (final AccessControlException e) {
        try {
            e.printStackTrace(new PrintStream("out2.txt"));
        } catch (IOException ex) {
        }
        return false;
    }
}

When running the above code in the Netbeans debug environment the above code returns true 在Netbeans调试环境中运行上述代码时,上面的代码返回true

but when complied to a .jar and run by simply double clicking the icon it will return false and I'm at a loss as to why. 但是当你遵守.jar并通过简单地双击图标来运行时,它将返回false并且我不知道为什么。

I've tried self signing the jar but this did not help. 我试过自己签了罐子,但这没有帮助。

验证您的计算机是否具有防火墙活动,或者对SO中的执行执行jar权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM