java.util.PropertyPermission user.home read (Access Denied)

World picture World · Nov 15, 2011 · Viewed 25.4k times · Source

I have a signed applet in which i have used JFilechooser to browse file from local file system for uploading. It runs properly in windows and mac. But in linux it shows error Access Denied (java.util.PropertyPermission user.home read). I searched in the internet and found one solution. I did accordingly, however could not solve the problem.

I created file .java.policy file inside my home folder.

grant codeBase "http://bioinfo.utu.fi/applet/*" {
  permission java.io.FilePermission "/home/raj/-", "read";
  permission java.io.FilePermission "/home/raj/-", "write, delete";
};

I could not get JFileChooser dialogue in Linux when i click "Browse" button, but shows Exception: Access Denied (java.util.PropertyPermission user.home read). How can i run it in Linux? I appreciate your help.

Recent Update:

I searched java.policy file from the terminal

[raj@localhost Desktop]$ locate java.policy
/home/raj/.java.policy
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/security/java.policy

I added following lines in the file /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/security/java.policy

grant{
    ...
    ...
    permission java.util.PropertyPermission "user.home", "read";
        permission java.io.FilePermission "/home/raj", "read";
    permission java.io.FilePermission "${user.home}${/}*", "read,write";

    }

Noe i can see JFileChoose Dialogue. Now i got another problem. I could not see and files on home directory in the applet file chooser dialogue.

Answer

user592704 picture user592704 · Nov 17, 2011

The problem may be much deeper it seems to...

Have you checked the user.home with not an applet but a local util? Is it "?" or something not like an absolute path?

I do recommend you to check it with System.getProperty("user.home") but with a desktop util;

Also there can be a client machine problem as 32-bit JDK . It is a well known bug so maybe that is the problem.

Please report that helps