accessing computer files

My applet tries to read a computer file (i created it). But 'cos it's an applet, there's some SecurityManager which p[revents me from reading the file.

I tried calling a frame to read it instead, but it's the same error. Applet and frame r both executed in browsers.

If I use kawa (an IDE for jdk), it can read and there's also a securitymanager. But the toString() gave a different msg.

How do I either disable the security manager or "ask" it to let my program pass so tat i can read the file?
If i deicde to use frame for the reading ie no applet at all, how do users execute the program (extends Frame)?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I'll address #2 b/c i'm not so sure about #1 but i know it's possible (you've seen those dialogs: "this applet wants to do xyz to your computer, ok to continue" this is probably what you want)
but for #2: what you're talking about is an "application" as opposed to an applet, you could send the users the class files and have them run one of the classes (needs to have a public static void main(String[] args) method that's run on startup).  but you want option 1 anyway which i'm pretty sure requires you to obtain a security certificate and sign the applet... someone else here will be able to fill in the details

From: vladi21
 Date: Tuesday, November 16 1999 - 08:46PM CST  
U Have to sing the applet to access any resource. 

Code signing resources:

Creating Signed, Persistent Java Applets 



NN: Bypass the need for a certificate
Netscape provides a way to accept a codebase as trusted (then a certificate is not needed). This can be useful during development or in a private Intranet. In the Netscape Users directory, there is a file called prefs.js. Adding the line user_pref("signed.applets.codebase_principal_support", true);

will enable JAR file without a certificate to request privileges on your machine. If you agree, it will be possible for an Applet to lauch a program, write a file on your hard disk or print on the printer. You will still have to ask for privileges in your program using the Netscape capabilites classes.
Another way is to lower general security setting to more allow more freedom when running applets locally. Add or modify the following entries in the prefs.js: user_pref("unsigned.applets.low_security_for_local_classes", true);
user_pref("signed.applets.local_classes_have_30_powers", true);
user_pref("signed.applets.low_security_for_local_classes", true);
user_pref("signed.applets.verbose_security_exception", true);

Then you don't need to asked for privileges for local classes.
When adding or modifying the file prefs.js, Netscape must not be running because your modification will be overwritten. So shut down Netscape, edit the prefs.js and then restart Netscape.

Running signed applets with the JavaTM Plug-in 



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
java_kevinAuthor Commented:
Adjusted points to 150
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

java_kevinAuthor Commented:
Wondering how to separate the pts to the 2 of you though...

I don't think I'd welcome those messages saying "applet wanna do soemthing". This will frighten my users. The applet I'm trying to do is basically a simple program for people to play, and their results will be stored and read on their computers during play.

In the doc suggezted, it says it can access local files. But mine can't seem to do it. It's merely accessing files of the same directory. OR maybe I can try to specify the directory and the file name so that it knows it's accessing a local file? Will try c:\... and file:///...

As for editing of .js, what if users are using IE? Won't it be risky? I mean, if they visit sites with applets that may do something malicious to their computer, it'll be disastrous.
But if I try using Netscape and include codebase in my html, will it work?

As for using frame, it's just that in case applet can't read from files, I can switch to frame. But for frames, they must be activated under java-installed computers. Applets can be activated in normal browsers.

Anyway, is frame better or applet? And does (extends) frame provide Graphics object as (extends) applet does? Or, in order to use Graphics object, I must have extends Applet?
the standard way of separating points is deleting this question and posting others with "to java_kevin" in the subject for x/2 points...

those warning messages are the crux of the security system that makes it ok to download and run code from the internet!  i would have java turned off in my browser if you could simply bypass them
java_kevinAuthor Commented:
Adjusted points to 250
java_kevinAuthor Commented:

So, how do I state/specify that it's a local drive? As browsers don't allow access to network?

And is there a way to see if an applet has got back the focus? ie, it opens a frame, and when the frame is closed, something happens.

Lastly, in the docs, it says including the codebase may help. How do I include that?

Thanks (increased marks)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.