Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to place java applet policy file?

I am working on an artificial intelligence project which is a logic game and aims two user connecting to the server on the network who acts as an Admin and then start to play one by one.

In order to create connections, i have a server code which is just listening on localhost:8000 and assigning team values to the clients as they arrive. After connecting, clients make their move under Admin's control.

The question is that when i try to put my code to work in the browser it fails with the following error:

java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:8000 connect,resolve)

Even though i have created my own policy, first granting only Socket access permission to the codebase of my project folder (file:///home/xxx/projects/-), after it didn't work i granted all permissions from all codebase. I tried placing my policy file both in the home directory and in the same directory where my applet code resides.

Appreciate any tips, thanks.

like image 922
makdere Avatar asked Apr 10 '10 09:04

makdere


People also ask

Where is Java policy file located?

policy file is located in the java_home /jre/lib/security directory. For all JVMs, the java. policy file is used system-wide.

What is Java policy file?

The java. policy file installed with the JDK grants all permissions to standard extensions, allows anyone to listen on un-privileged ports, and allows any code to read certain "standard" properties that are not security-sensitive, such as the " os.name " and " file.

Where is Java security properties file?

Whenever you run an applet, or an application with a security manager, the policy files that are loaded and used by default are the ones specified in the "security properties file", which is located in one of the following directories: Windows: java. home\lib\security\java. security.


2 Answers

by default I think it looks for a file named .java.policy in your home directory

you can check the file /lib/security/java.security to see where it looks. check the keys named policy.url.n

like image 143
objects Avatar answered Sep 26 '22 05:09

objects


You can set the location of the security policy file by using this command-line option

-Djava.security.policy=policyfilepath

with the java command.

Or you can even set this propery using the System.setProperty() procedure.

like image 26
sdflkj Avatar answered Sep 27 '22 05:09

sdflkj