UNABLE TO FIND java.io.FilePermission to import
I am a new user of Java and have installed SDK1.3.1 on NT4.0 and am trying to write a file to my local directory via an applet.
It works fine with appletviewer but when I run it in IExplore it fails with a Java Console message...
com.ms.security.SecurityExceptionEx[Window3Base.writeIt]: java.io.IOException: bad path: E:\<local directory>\java\io\FilePermission.class
I have C:\WINNT\Java\Classes\classes.zip installed and in the CLASSPATH.
When I use MSVisualJ++, import does not see FilePermission in java.io.
Where can I find the FilePermission.class?
[619 byte] By [
bwakelam] at [2007-9-26 2:28:46]

> I am a new user of Java and have installed SDK1.3.1 on
> NT4.0 and am trying to write a file to my local
> directory via an applet.
>
> It works fine with appletviewer but when I run it in
> IExplore it fails with a Java Console message...
>
> com.ms.security.SecurityExceptionEx[Window3Base.writeIt
> : java.io.IOException: bad path: E:\<local
> directory>\java\io\FilePermission.class
>
> I have C:\WINNT\Java\Classes\classes.zip installed and
> in the CLASSPATH.
>
> When I use MSVisualJ++, import does not see
> FilePermission in java.io.
>
> Where can I find the FilePermission.class?
>
>
>
Hello.
It doesn't work not because you can't find the FilePermission.class but because the security model you are executing in doesn't allow you to do such things like write a file to the filesystem. Please review the applets documentation and you'll see what an applet is allowed to do and what not when running in a browser window.
Regards,
Rick
Thanks for your reply Rick, but if you read gumpngreen's response to 8infinity in the Java Programming Forum:
http://forums.java.sun.com/thread.jsp?forum=31&thread=140093
He says it is possible. I have tried what he suggests, but the compiler still does not see FilePermission.
My understanding is that the whole point of Java is that applets are restricted from accessing files unless specific security permissions are granted, which I have done via the policy file. hence the need for the FilePermission class.
Thanks again.
Bob
So either you didn't gimmick the policy file right, or you didn't put it in the right place, or you have to close and reopen the browser to make the change take effect, or something else. May I ask why you chose to write an applet to do this? If you had written an application, you wouldn't have to fight against the applet security rules.
Thanks for your suggestions DrClap.
Unfortunately, the policy file is correct and in the correct location, and I have opened the browser many times on this applet.
My problem is the compiler can not find FilePermission.class
It is supposed to be at java.io.FilePermission
but java.io does not contain FilePermission on my laptop, when I import it manually or in MSVisualJ++.
The compiler error is a class not found: FilePermission.class
and the Java Console tells me it cannot find FilePermission.class when I run the applet in IExplore.
So where is FilePermission? ...if it is not in java.io where the documentation says it is.
Do you know if there is another class package that I need to install to find FilePermission?
The reason I am attempting an applet is because I wish eventually to run this software over the internet, but at present need only to test it on my local machine while I am developing it.
Any ideas, DrClap?
Bob
I'm not clear on what the problem is.
On one hand, you say that the compiler cannot find a specific file. If that's the case, no class file would be generated. However, on the other hand, you say that it works fine on appletviewer. Therefore you must have a class file.
Which of the following two is the case? (It can only be one!)
1. There is a compiler error with importing the package and no class file is produced.
2. The class compiles, but you get a runtime error when you run the class.
Well spotted schapel,
I get the compiler error:
Undefined name 'java.io.FilePermission' (J0049)
generated from import java.io.FilePermission when I build the java file in MSVisualJ++.
But if I run javac in a DOS shell on the same java file it compiles without error!
Then, when I run the HTML file I get the runtime error:
com.ms.security.SecurityExceptionEx[Window3Base.writeIt]: java.io.IOException: bad path: E:\<local folder>\java\io\FilePermission.class
generated in the Java Console when the applet runs in IExplore.
There is only one javac.exe on my machine, in jdk1.3.1\bin
Go figure!
I just want to know why it can't find FilePermission in either case.
Any ideas schapel?
Bob
I think the issue may be this:
java.io.FilePermission exists only in JDK1.2 and above.
In MSVisualJ++, you only have access to JDK1.1.8 (and therefore no java.io.FilePermission)
At the DOS prompt, you have access to whatever the latest JDK is that you have installed (looks like it's 1.3.1) - so here you *can* access java.io.FilePermission...
I'd suspect classpath. It looks like the IDE's classpath, and the browser's classpath to be incorrect, which the command line tool's classpath is correct.
That was the *compilation* issue I was talking about, BTW...
Although it would probably explain the browser issue too - the standard browser JRE is 1.1.8 only, unless the javaplugin is installed. Appletviewer has access to the latest JRE on your machine, however