1,105,556 Community Members

applet

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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" "127.0.0.1:3000" "connect,resolve")
even i give the applet the folllowing permission
grant{
permission java.security.SocketPermission "127.0.0.1:3000" "connect,accept,listen,resolve";
};

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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 127.0.0.1?

i give the applet the folllowing permission

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

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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:
System.out.println(System.getProperties().getProperty("user.home"));
The filename must be: .java.policy

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

Create a ,java.policy file in that folder.

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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")

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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.

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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";
};

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

where is the problem if i give it that name

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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?

Member Avatar
lena1990
Posting Whiz in Training
202 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article