We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,633 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

applet

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

4
Contributors
24
Replies
3 Days
Discussion Span
1 Year Ago
Last Updated
25
Views
lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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?

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

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

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

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

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

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

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Create a ,java.policy file in that folder.

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

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

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

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

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

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

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

where is the problem if i give it that name

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

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

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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"/>

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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?

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

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

lena1990
Junior Poster
123 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.1593 seconds using 2.83MB