Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Applets and server files

Applets and server files
Thread Tools
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Mar 6, 2001, 09:26 AM
 
This might not be the best place to post this question but whatever.
I am trying to run some Java Applets on my OS X machine (using it as a test server) that I will later use on a Solaris Web Server to edit server-side files. I keep getting an Security Exception when I run the applet through a browser even though I am trying to look at a file on the server which _should_ be ok. I am assuming then that I have not accessed the file properly so it is looking on a client machine (which, when unsigned, is illegal). I am just using a "FileReader" object so this may not support connections to the server. If anyone has the solution or a code snippet that will do this can you post it? I have been hacking away at this for days and cannot get around this exception.

Thanks in advance,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Dedicated MacNNer
Join Date: Nov 1999
Location: Georgetown, Demerara, Guyana
Status: Offline
Reply With Quote
Mar 8, 2001, 12:27 PM
 
Hi Jeff,

There could be a number of reasons why a security exception is being thrown... Since you're using a FileReader object, which I believe can only read local files, I assume that both your browser and your file (that the applet is trying to access) reside on the same Mac OS X server? If that's the case, then I'm afraid that you're right about the security issue. It wouldn't matter that the applet is being loaded "locally"; it would still be treated as an untrusted downloaded applet without local I/O privileges, at least in pure Java 1 (JDK 1.1.x).

However, there might be a way to work around this if your Mac OS X user account normally has read-permission for that file. For instance, perhaps you could try specifying the applet's CODE= tag as a local path instead of a 'file://' URL, and also adding its classes to the global class-path of the active JVM?

If that doesn't work, then you could try a browser-specific approach, as a long shot. I guess you're using the new "carbonised" version of MS Internet Explorer for Mac OS X? I myself haven't used that IE yet (or Mac OS X much, for that matter). However, if it's similar to recent versions of IE for Mac OS Classic, then it should allow selecting Apple's MRJ Java Virtual Machine (JVM) instead of MS' JVM in the Java panel of the Preferences dialogue. If so, the MRJ security options would then appear, and you might be able to use them to control an applet's access to local and/or remote files. E.g., unchecking the 'Restrict Access to Non-Java class files' option would supposedly allow an applet to access local files other than Java sources/archives. (Although, I'm not certain how these options tie into the pure Java 1 model.)

If that doesn't make any difference either, or if my assumptions about your setup are completely wrong, then there are some other approaches that might work. E.g., you could switch to accessing your file remotely via a URLConnection object rather than a FileReader one. Or, if Mac OS X PB comes with Java 2 (JDK 1.2+) instead of or along with Java 1, then you could probably use the new Java 2 security API to let your applet have "local" I/O privileges, just for your testing phase...

[BTW, in case you haven't already seen them, there are some useful Java FAQs listed at the Java FAQ Archives website.]

Regards,

--Paul

[This message has been edited by Paul Crawford (edited 03-08-2001).]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:02 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2