2

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.

Roman C
  • 49,761
  • 33
  • 66
  • 176
World
  • 2,007
  • 7
  • 27
  • 37

1 Answers1

-1

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

user592704
  • 3,674
  • 11
  • 70
  • 107
  • I tried with desktop application. System.out.println(System.getProperty("user.home")). It shows correct home directory. What i knew is that applet required two permissions java.io.FilePermission and java.util.PropertyPermission. I added both permission in java.policy file. Now i can see the JFileChoose dialogue but could not see nay files on the home directory. – World Nov 22 '11 at 13:02
  • Emm... are you trying to use user.home as a start point of your jfilechooser? As an alt try to set some different start point; I mean this method http://docs.oracle.com/javase/1.5.0/docs/api/javax/swing/JFileChooser.html#setCurrentDirectory%28java.io.File%29 ; please report that helps – user592704 Nov 23 '11 at 13:20
  • And tell me your linux jre version please – user592704 Nov 23 '11 at 13:25
  • yes i am trying user.home as starting point of JFileChooser.I have used the same method you mentioned setCurrentDirectory(). My Java version is *java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.10) (fedora-55.1.9.10.fc14-i386) OpenJDK Server VM (build 19.0-b09, mixed mode)* – World Nov 24 '11 at 07:45
  • Emm... have you tried to use setCurrentDirectory() for some other location? I mean not for the user.home only? – user592704 Nov 25 '11 at 00:34
  • And was the applet certificate added to jre trusted certificates storage? Can you see the certificate in the certificates list? – user592704 Nov 25 '11 at 00:41
  • The problem is the `AccessControlException` reading the property, not the content of the property. Read the question. – user207421 Nov 13 '16 at 22:53