Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Socket Permissions Problem using Java applet on Windows but not on Mac

 
Philip Underhill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with java.security.AccessControlException.access denied when using any Windows OS / Browser with my java applet.

I get a (java.net.socket permission [IP address]:PORT connect, resolve) error.

However, when I use a Mac OS / Browser the applet works correctly?

The service is running on a Tomcat server and I have looked into security policies but I am new to java applets / sockets etc so I am looking for some guidance.

The applet function basically allows files to be uploaded/downloaded using a MySQL database.

Can anyone help please?

Thanks



 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Please read this for applet security issues.

I'll move this thread to our Applets forum.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 things you need to do.
1. Get the system security manager to do accept your permission checks. Here are 2 examples :

Replace xxx.xxx.xxx.xxx with the server IP address.

The RunTime is for a thread (obviously).
Put the needed lines as your first code in the main method.


2. You have to sign the JAR file
i.
Fill out all this information. It will create a keystore named "keystore" (you can change it to whatever name you would like)
ii. Put a certificate on it. You could pay to have it certificated or sign it yourself :

iii.

NOTE: Remember the passwords you put in these.

Enjoy!
John Price
 
Nam Ha
Ranch Hand
Posts: 50
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you signed the applet and all external libraries (jars), you do not need to write permission checking code.
Remember to sign external jars as well, not only the Applet jar itself. I had permission exception problem and had not figured out until I found some external jars were not signed. I signed all of them then everything was fine.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may also habe to run the code as privileged code, which is described in the link Rob posted.
 
Philip Underhill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the suggestions.

I will try the jar signing and see what results I get. I am new to this so I don't want to rush into things.

Does it make any sense that the applet works in a Mac environment and not Windows?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic