create a file at a Windows Vista using java applets

I have created a java applet which is downloaded to create local file at a Windows Vista PC. The java codes are:

File out = new File("c:/users/test/hkuesd.properties");

FileWriter fw = new FileWriter(out);

PrintWriter pw = new PrintWriter(fw, true);

pw.println("#sample property file");

pw.println("key_path=C:/");

pw.close();

fw.close();

If I turn off "Users Account Control" under "Control Panel" --> "User Accounts", the file "hkuesd.properties" is created at c:\users\test and can be found using windows explorer.

However, if I turn on "Users Account Control", I can not find the file "hkuesd.properties" using windows explorer. But the file can be detected if I run another java applet program with the following codes:

File xpdir = new File("c:/users/test/hkuesd.properties");

FileInputStream fis = null;

if (xpdir.exists()) {

try {

fis = new FileInputStream("c:/users/test/hkuesd.properties");

Properties p = new Properties();

p.load(fis);

fis.close();

privateKeyPath = p.getProperty("key_path", "no value");

}

catch (Exception e) {}

}

Interestingly, if "Users Account Control" is on and I created the file "c:\users\test\hkuesd.properties" manually, the file creation codes

mentioned above seems to create another "hkuesd.properties" at the same "c:\users\test". The evidence is I run the second java applet program which can detect the one created by the first java applet but not the one I created manually.

[1570 byte] By [hcxcltya] at [2007-11-26 18:32:18]
# 1

Kinda confused as to what is going on but a couple questions. Have you tried searching for the file when you think it is missing? Maybe it is being put in a different directory? I see you are swallowing exceptions, so you would not know if something is wrong. Change the code and see if any exceptions occur.

zadoka at 2007-7-9 6:06:24 > top of Java-index,Desktop,Runtime Environment...
# 2

I agreed that it is hardly explained in words. I suggested to write two

simple java applets using the codes and you will see the effects:

(1) the first applet can create a file "hkuesd.properties"

(2) cannot find the file using windows explorer to search the whole drive.

(3) However, can read the content of the file using second applet.

hcxcltya at 2007-7-9 6:06:24 > top of Java-index,Desktop,Runtime Environment...
# 3

> I agreed that it is hardly explained in words. I

> suggested to write two

> simple java applets using the codes and you will see

> the effects:

>

> (1) the first applet can create a file

> "hkuesd.properties"

>

> (2) cannot find the file using windows explorer to

> search the whole drive.

>

> (3) However, can read the content of the file using

> second applet.

You still haven't address your problem of swallowing exceptions. Your code might be throwing an exception that tells you exactly what the problem is. Change your code to display or log that exception.

zadoka at 2007-7-9 6:06:24 > top of Java-index,Desktop,Runtime Environment...
# 4
There is no exception or error messages catched after I includedthe statements within the catch statement:e.printStackTrace();
hcxcltya at 2007-7-9 6:06:24 > top of Java-index,Desktop,Runtime Environment...
# 5
leave it as it is and read some extrait may be a bug or something like that
prashantmalik.iec@gmail.coma at 2007-7-9 6:06:24 > top of Java-index,Desktop,Runtime Environment...
# 6
I am not sure whether it is a bug related to Java or MS Vista. Can SUN experts investigate my findigs?
hcxcltya at 2007-7-9 6:06:24 > top of Java-index,Desktop,Runtime Environment...
# 7

Windows Vista has a more restrictive security model, even for signed applets. There is a (brief) note about this in the Java SE 6 release notes at

http://java.sun.com/javase/6/webnotes/#windowsvista

Also see Chet Haas' blog at

http://weblogs.java.net/blog/chet/archive/2006/10/java_on_vista_y.html

which has a bit more detail.

jxca at 2007-7-9 6:06:24 > top of Java-index,Desktop,Runtime Environment...