andrew
andrew

Reputation: 9583

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

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.

I've tried self signing the jar but this did not help.

Upvotes: 3

Views: 67

Answers (1)

Eder F. Freitas
Eder F. Freitas

Reputation: 48

Verify if your machine has a firewall active, or jar permissions to executions in S.O.

Upvotes: 1

Related Questions