Getting current directory from an applet

Hi. How can I get the current directory of my applet running on web without having to worry about permissin. I used the one below:

curDir = System.getProperty("user.dir");

but I get this error:

ava.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)

at java.security.AccessControlContext.checkPermission(Unknown Source)

any substiture for this? Thanks.

[430 byte] By [Kaela] at [2007-11-27 3:51:12]
# 1
And by the way, I already set the the attributes of the folder to 777.
Kaela at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 2
"Current directory" is a meaningless concept for an applet. Why do you think you need to know it?
DrClapa at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 3
I just want to make sure that i'm on the right path.. why is it meaningless? thanks.
Kaela at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 4
> I just want to make sure that i'm on the right path.That sentence makes me nervous, on more than one level.
DrLaszloJamfa at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 5

was trying to read from a text file but it's giving me some diffrent error messages so i decide d to show the path to make sure that it can see the file.

is it possible for an applet to read directory structure of my server cuz I'm getting a permissin problem still even though the atributes are all set to 777 from parent folder down to the last one.

Thanks.

Message was edited by:

Kael

Kaela at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 6
You want your applet to read the directory structure on the server? Do you realize it's running on the client, not the server, and that applets have severe restrictions on what they may do?What are you trying to do, what is your goal?
DrLaszloJamfa at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 7
i have a text file that contains the value for my applet's combo box. so if need to add a new value, i just have to add it to my text file.thanks.
Kaela at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 8
if that's the case, I need to do a direct path to my server then likewww.name.com/files/values.txt?thanks.
Kaela at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 9

You should be using URLs or similar approaches, and avoiding File, which will

never work with an ordinary applet.

InputStream in = this.getClass().getResourceAsStream("file.txt");

That assumes the txt file is in the same place as the current classes .class file.

For example, the same folder or that they are jarred in the same "folder" in the jar.

You can also use a URL directly:

URL url = ...

InputStream in = url.openStream();

and you can construct that URL with the help of Applet methods getDocumentBase or getCodeBase:

URL url = new URL(this.getDocumentBase(), "file.txt");

That assumes the txt file is in the same folder as the html file in which the applet is embedded.

DrLaszloJamfa at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 10
Thanks Doc. You rock!!!
Kaela at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...
# 11
> Thanks Doc. You rock!!!Glad I could help. Most limitations on applets are dead ends.
DrLaszloJamfa at 2007-7-12 8:55:10 > top of Java-index,Java Essentials,New To Java...