hi all
i have applet that i want to connect to the server when i run the applet from the appletviewer the applet connect to the server ,but when i run the applet from web browser i have the following exception
java.security.AccessControlException: access denied ("java.net.SocketPermission" "" "connect,resolve")
even i give the applet the folllowing permission
permission java.security.SocketPermission "" "connect,accept,listen,resolve";

Applets are restricted in what they can do. They need permission to connect to a site if they were not loaded from that site. Are you loading the html with the applet from a server at

i give the applet the folllowing permission

Where is the policy file with that statement? How are you giving the applet the permission?

i give the applet permission through policytool and i load the html from a server at

Where is the policy file located? Is it in the correct folder where the Java program looks for it?

i place my program that is named pro at f:/pro and the policy located at f:/pro/applet.policy and the web page that call the applet at f:/dist/launch.html

The java program looks in the user.home directory for the .java.policy file. There are ways to tell it to look in other locations. I don't know how to do it for the java plugin running in a browser. Execute this statement in a test program to find the user.home folder:
The filename must be: .java.policy

i print that statement and i get the following D:\Documents and Settings\ali so what i can do?

Create a ,java.policy file in that folder.

do you mean i go at the policy file and create a policy file in this location that specfies the permission for an applet

Yes, That location is where the java program will look for the .java.policy file to use.

i do what you say but i get the following exceptionjava.security.AccessControlException: access denied ("java.util.PropertyPermission" "" "read,write")
java.security.AccessControlException: access denied ("java.util.PropertyPermission" "
" "read,write")

Everything must be right or it won't work,
Is the policy correctly named? What is its name?
Is the policy file in the correct location? Where is it located?
How did you create the policy file?
What is the contents of the policy file? Does it have the right code base and permissions granted? Notice the name of the permission in the error message.

the policy file named applet.policy and it is located in D:\Documents and Settings\ali\applet.policy i created using policy tool and the content of policy file isgrant {
permission java.security.AllPermission;
permission java.util.PropertyPermission "*", "read, write";

Why did you give the file that name? Why do you think the java program will find it?

where is the problem if i give it that name

How does the java program know the name that you have given the policy file?

i get the following exception
access denied ("java.net.SocketPermission" "" "connect,resolve")

i have this code to make the java know about the applet
<j2se java-vm-args="-Djava.security.policy=applet.policy" version="1.7+"/>
<jar href="pro.jar" main="true"/>

What program reads and uses those lines? What file are they in? How does the program find the policy file? What folders does it look in?

i use netbeans and ther are in the file named launch.jar

Sorry, I don't know anything about your IDE or how to use it.

i can use jbulider do you know any thing about it

I don't use an IDE when executing applets in a browser from a site or from a local html file. I give the applets permissions by making changes to the .java.policy file using policytool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.