Applet + Read File??????

Hello security gurus:
Could somebody suggest an easy way to read a single xml file from originating on the same sever and directory where the applet resides? People say that an applet can access file from the working directory and all sub-directories this works fine on my system when
executed directly from the appletviewer or the browser but when I load my program and it's dependencies in a webserver such as tomcat or apache it chokes on applet security exceptions. If someone could help I could stop
beating my head on the desk where my workstation resides.
Thanks, Ian

Hi Bakrudeen,
I�m a newbie into Java Applets ( so, Java too ), I work with C and C++, but now I need to do somethings using Java. One it�s that I need to do a Applet that read a xml file that�s into my webserver, in the same direcotry that my .class files are. First, I did a java class that run stand alone, it read the file perfectly, after I did a class that extends the applet class, but it didn�t found. Reading your e-mail, I had some questions, than, can you explain better your ideas ? Because, I have the plugins in my machine ( not in the server, the server doesn�t have anything about java, only the Apache server, my webpages and applet classes ), but I can�t read the file ? Another question is: how can I do to see the exceptions messagens to try looking for my errors ?
See below the source code that I�m trying to use:
import javax.swing.*;
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import org.w3c.dom.Document;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class WS10Parser extends Applet {
public int finished;     // 0 - n�o encerrado
// 1 - encerrado
// 2 - erro
private JanelTexto janela;
public void init() {
janela = new JanelTexto();
public void paint(Graphics g) {
//          g.drawString("Welcome to Java!!", 50, 60 );
* Fun��o para leitura do arquivo XML
* Parametros:
* - Nome do arquivo XML a ser lido
* - Nome do Dispositivo a ser lido
* - Modo de leitura do arquivo
*     - 1 L� somente dados referentes ao dispositivo identificado pelo Nome
*     - 0     L� informa��es de todos os Devices no arquivo
//     public void ReadFile(String FileName, String DeviceName, int Mode) {
public void ReadFile(String FileName) {
finished = 0;
URL url;
try {
url = new URL(getCodeBase(), FileName);
janela.AddText("File name: " + url.toString());
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(url.openStream());
// normalize text representation
doc.getDocumentElement().normalize();
janela.AddText("Root element of the doc is " + doc.getDocumentElement().getNodeName());
NodeList listOfDevices = doc.getElementsByTagName("device");
int totalDevices = listOfDevices.getLength();
janela.AddText("Total no of devices : " + totalDevices);
for(int s=0; s<listOfDevices.getLength() ; s++){
Node firstDeviceNode = listOfDevices.item(s);
if(firstDeviceNode.getNodeType() == Node.ELEMENT_NODE){
Element firstDeviceElement = (Element)firstDeviceNode;
NodeList firstNameList = firstDeviceElement.getElementsByTagName("name");
Element firstNameElement = (Element)firstNameList.item(0);
NodeList textFNList = firstNameElement.getChildNodes();
janela.AddText("Device Name : " + ((Node)textFNList.item(0)).getNodeValue().trim());
NodeList lastNameList = firstDeviceElement.getElementsByTagName("timestamp");
Element lastNameElement = (Element)lastNameList.item(0);
NodeList textLNList = lastNameElement.getChildNodes();
janela.AddText("TimeStamp : " + ((Node)textLNList.item(0)).getNodeValue().trim());
NodeList listOfChannels = firstDeviceElement.getElementsByTagName("channel");
int totalChannels = listOfChannels.getLength();
janela.AddText("Total no of channels: " + totalChannels);
for(int cont = 0; cont < listOfChannels.getLength(); cont++) {
Node channelNode = listOfChannels.item(cont);
if(channelNode.getNodeType() == Node.ELEMENT_NODE) {
Element channelElement = (Element)channelNode;
NodeList tagList = channelElement.getElementsByTagName("tag");
Element tagElement = (Element)tagList.item(0);
NodeList textTagList = tagElement.getChildNodes();
janela.AddText("Tag: " + ((Node)textTagList.item(0)).getNodeValue().trim());
NodeList valueList = channelElement.getElementsByTagName("value");
Element valueElement = (Element)valueList.item(0);
NodeList textValueList = valueElement.getChildNodes();
janela.AddText("Value: " + ((Node)textValueList.item(0)).getNodeValue().trim());
}//end of if clause
}//end of for loop with s var
finished = 1;
}catch (SAXParseException err) {
janela.AddText("** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId());
janela.AddText(" " + err.getMessage());
finished = 2;
}catch (SAXException e) {
Exception x = e.getException();
((x == null) ? e : x).printStackTrace();
finished = 3;
}catch (Throwable t) {
t.printStackTrace();
finished = 4;
private class JanelTexto extends JFrame {
private JTextArea ta;
public JanelTexto() {
super("Teste Applet Novus");
Box b = Box.createHorizontalBox();
ta = new JTextArea(20, 30);
b.add(new JScrollPane(ta));
Container c = getContentPane();
c.add(b);
setSize(425, 200);
show();
public void AddText(String Text) {
ta.append(Text + '\n');
Thanks

Similar Messages

  • Applet read file on web

    Can applet read file on web?
    I try to write an applet that read the file on web i.e. http://lcoalhost:8080/test.txt
    The HTML page contain the applet is placed on http://localhost:8080
    URI URItemp= new URI("file:///test.txt");
    File Filetemp = new File(URItemp);
    BufferReader in = new BufferReader(new InputStreamReader(new FileInputStream(Filetemp)));the above cannot work
    Error : access denied (java.io.FilePermission \test.txt read)
    And then I add
    FilePermission fp = new java.io.FilePermission("file:///test.txt", "read");still cannot work
    Cound anyone tell me that is possible to do what I want to do?
    If yes, how?
    Thanks!!

    Applets are downloaded from web servers and execute on the client machine.
    Therefore they have no access to the web server file system, signed or not.
    They could have access to the client file system (the machine where they run),
    but for security reasons only signed applets have this privilege.
    So to answer your question, you sign if you want to access client files.
    To access web server files, you don't need to sign the applet, but you need
    to provide some method of accessing files remotely, for instance:
    - Files published for the web can be read using HTTP
    - Files can be read or writen with the help of an FTP server on the same machine as the web server
    - A servlet running on the HTTP server can collaborate with your applet to exchange files

  • Applet reading files in in web server eg geocities

    hi ,
    i have an applet that reads files i have created in a web server. when i try to run the applet in , internet explorer i get an error message
    java.io.FileNotFoundException: nic.txt (The system cannot find the file specified)
    does anyone have any solution to this problem. do i need a policy file and if i do where do i put it.

    Applets work on the clients computer, not the server. Your applet is >trying to read nic.txt from your computer. Can't be done easily, you'd >need your own serverprogram to do the reading and pass the data to the >client... let me clarify afew points
    the applet is on a webserver eg. geocities.
    the file is also on the same directory as the applet .class file.
    so everything is on the web server,.

  • URGETN HELP NEEDED! JAVA APPLET READING FILE

    Hi everyone
    I need to hand in this assignment today
    Im trying to read from a file and read it onto the screen, my code keeps showing up an error
    'missing method body, or declare abstract'
    This is coming up for the
    public statuc void main(String[] args);
    and the
    public void init();
    Here is my code:
    import java.io.*;
    import java.awt.*;
    import java.applet.*;
    public class Empty_3 extends Applet {
    TextArea ta = new TextArea();
    public static void main(String[] args);
    public void init();
    setLayout(new BorderLayout());
    add(ta, BorderLayout.CENTER);
    try {
    InputStream in =
    getClass().getResourceAsStream("test1.txt");
    InputStreamReader isr =
    new InputStreamReader(in);
    BufferedReader br =
    new BufferedReader(isr);
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    String line;
    while ((line = br.readLine()) != null) {
    pw.println(line);
    ta.setText(sw.toString());
    } catch (IOException io) {
    ta.setText("Ooops");
    Can anyone help me please?
    Is this the best way of doing this? Once i read the file i want to perform a frequency analysis on the words so if there is a better method for this then please let me know!
    Thankyou
    Matt

    Whether it is urgent or not, does not interest us. It might be urgent for you but for nobody else.
    Writing all-capitals is considered shouting and rude.
    // Use code tags for source.

  • Applets reading files in their own jar file

    I know there is no way to get my applet to read a file on the hard disk. But
    could I read one that I include in with the .jar file that I create for my applet?
    What about using a Resource type of file? Is this possible?
    Thanks

    Here's a little code stub I used to read a properties file from rt.jar    Properties p = new Properties();
        InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream
         ("java/awt/resources/awt.properties");
        if (is == null) System.out.println("NULL");
        else try { p.load(is); }
        catch (Exception exc) { System.out.println("Exception"); }
        p.list(System.out);You should be able to substitute your path & properties file

  • How do I make an Applet read a file on my web host?

    How do I make an Applet read a file on my web host?
    I am wanting to put a file on my web host that has usernames and user details and other stuff on it...
    I was wondering whether anyone knows how to make the Applet open a file on my webserver, check if the username exists, if not add to the file the username and details?
    thanks

    URL myURL = new URL(getDocumentBase(), filename);
    InputStream myInputStream = myURL.openStream();
    DataInputStream dis = new DataInputStream(myInputStream);
    String oneLine = dis.readLine();
    Use output stream for writing..
    hope this works !!!

  • Reading file in Applet.

    Hello All,
    i am trying to read a file in applet. i have created a applet that reads file and prints its content. it works fine on local system but when i publish this applet in web server it gives such exceptions.
    java.security.PrivilegedActionException: java.lang.reflect.InvocationTargetException
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.liveconnect.SecureInvocation$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.liveconnect.SecureInvocation.CallMethod(Unknown Source)
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin.javascript.JSInvoke.invoke(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
         at sun.plugin.liveconnect.PrivilegedCallMethodAction.run(Unknown Source)
         ... 4 more
    Caused by: java.security.AccessControlException: access denied (java.io.FilePermission C:\reading\run.bat read)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkRead(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at readFile.showContent(readFile.java:38)
    Can some body say whats going on?
    I am stuck over here.
    Any help will be appreciated.
    Regards
    Jaya N pasachhe.

    If you are surfing the web, and you click a link to a page that you don't know, you don't want some unknown Applet to start and be allowed access to your local harddrive or printer.
    Therefore, Applets ran by the browser, run in a so-called "sandbox". Read about it.
    The solution is to "sign" the applet's jar.
    see http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html
    and http://forum.java.sun.com/thread.jspa?threadID=174214

  • Writing applets that read files hosted on a webserver.

    I have a java applet that I need to be able to read files on the webserver. IE open and render images. I know ultimately the user will end up downloading these images that are hosted on the websserver, but the java applet is set to read from it's local directory, for example, when I open up a text files, I use the path someFolder\someFile.txt. If the applet was placed in the same folder as someFolder on the webserver, how would I set it up to read from there opposed to on the machine executing the java code? Would I have to force the user to download all the resources, in thus case, wouldn't I need to to have the applet signed?

    ++++ to everything by malcolmmc (use class.getResource())
    Jeremy.W wrote:
    ...I could perform a CRC check and compare the archives with the ones on the server, but it still means I'd need to compress the archives manually every time an update is made to the files on the server.I am not sure whether you are concerned with the effort of doing this from your side. If so, use Ant to make your ..war file or whatever and just upload it (and restart the server?).
    If it is the archives (Jar or Zip) updating on the client that is your major concern, then I would definitely recommend the JNLP based option, which gives the client not only automatic update (the JWS client manages the time checks with the server), but if you want to go that far, direct programmatic access to the download API. I made a crude example (never properly finished) of downloading resources using the JNLP APIs DownloadService. (Though the standard 'auto-update' is known to be quite effective).
    Oh, and.. Of course, if you have a Java enabled server, the download servlet is known to be best for updates, incremental or otherwise.
    Does this applet really need to be embedded in a web page at all? JWS has offered these things to free-floating applets since Java 1.2, it is only recently an embedded applet could hook into the JNLP API.
    As to the 'Zip' archives of resources. Some points:
    1) It pays to split them up, especially if resources are likely to change frequently in one, but rarely for others. If you do that, webstart ensures the user only downloads the updated Jars. The only way to achieve a class/resource refresh in a conventional embedded applet ('plugin1') was to flush the class cache which would force refresh of all classes/resources.
    2) Splitting the archives according to type of resource can provide benefits in that the Jars can have different compression levels appropriate to the format.
    3) I would recommend deploying all resources, whether classes or other resources, in Jar and not Zip files. Sun has decided that no Zip will be checked to see if it is digitally signed, so Zip archives can cause problems for apps. which might need extended permissions (if it ever comes to that).

  • Applets and File I/O

    As an attempt to familiarize myself with Java, I decided to create an applet to display my collection of collectible trading cards so that other collectors could view it and offer trades. The data is stored in a .txt file, which the applet reads when setting things up. The data is never edited by the applet, only read. Everything is working fine until I put the applet on the web page.
    At first, I ran into the security problem that it appears others have run into, and I searched the forums to figure out what to do about that. I'm not getting security exceptions any longer, I'm merely getting a "File Not Found" issue instead.
    The data file is included in the .jar file, so I didn't think I'd have to do anything other than this when I try to open the file stream:
    dataFile = new Scanner(new BufferedReader(new FileReader("MTDBData.txt")));;
    But this is what I see when I attempt to open the page:
    mDNSResponder: mDNS_SetPrimaryInterfaceInfo V4 address - incorrect type. Discarding.
    Exception: MTDBData.txt (No such file or directory)
    java.lang.NullPointerException
    at ListData.initializeListData(ListData.java:194)
    at MTDBManager.init(MTDBManager.java:129)
    at MTDBApplet.init(MTDBApplet.java:10)
    at sun.applet.AppletPanel.run(AppletPanel.java:378)
    at java.lang.Thread.run(Thread.java:613)
    I also tried putting the data file in the same directory with the .jar file on the web page, but that isn't working either. Does the first line indicate that I am doing something wrong when generating the security keys? Or do I need to preface the filename with pathing information in order for the applet to find it?
    Any assistance would be appreciated. Thanks!
    -- Josh

    After some investigation, I added a getCodeBase() before the file name to tell it explicity where to look. Now I'm seeing this:
    Exception: http:/(URL omitted)/mtdb_data.txt (No such file or directory)
    java.lang.NullPointerException
         at ListData.initializeListData(ListData.java:215)
         at MTDBManager.init(MTDBManager.java:136)
         at MTDBApplet.init(MTDBApplet.java:10)
         at sun.applet.AppletPanel.run(AppletPanel.java:378)
         at java.lang.Thread.run(Thread.java:613)
    I changed the file name from before and omitted the first part of the URL for privacy reasons. But what baffles me is that I can paste the full URL for the file it says it can't find into my browser, and the file pops up exactly as I would expect. I've tried this on two different web pages, and the only differece in the error is the first part of the URL, so I know the getCodeBase call is working properly. Has anyone seen this problem where it can't find the file despite the URL being correct? More importantly, does anyone know what to do about it?
    -- Josh

  • Reading files from clients machine through a browser

    if i have to access or use some files say C:\hello\myimage.jpg from client machine's local drive, how it can be done using some technology in Java eg applets or some other way. please read the following situation to have a better undertsanding of the problem,
    consider the following situation:
    a web application is running on client PC, and on click of a button, i have to generate a report in some format and insert some images in that report which are on clients local drive and their path is known to me say C:\ myimage.jpg.
    if the mages were on the server(where web application is hosted), then its not a prob.
    if there any other technology in java to read files from clients PC through a browser other than java

    Sign the applet.
    http://forum.java.sun.com/thread.jspa?forumID=63&threadID=524815
    second and last post

  • Reading files from a browser on clients PC

    is there anyway to read files from clients PC through browser in java, apart from signed applets.....
    plz help , its very urgent......

    taking the browser to be IE, suppose the following situation:
    a web application is running on client PC, and on click of a button, i have to generate a report in some format and insert some images in that report which are on clients local drive and their path is known to me say C:\ myimage.jpg.
    if the mages were on the server(where web application is hosted), then its not a prob.[b]
    so for doing such a thing what i have to do means, what setting i have to change of the browser .....what security setting of clients PC has to be changed...
    and how to get jar signed.
    plz tell me the procedure to do this....

  • How to load an applet jar file?

    Hello everyone,
    I have an applet that uses my own jar file and approximately 6 third party jar files. I set up jar indexing (jar -i) which will download the jar files when they are needed. All seems to work well, but now I want to manually load the jar files which I cannot get working.
    When the applet starts, about 1/2 of the jar files are downloaded (because they are needed at startup). I then want to load the additional jar files in the background, after the gui is initialized. I have tried this using the below thread which is executed from within the applet's start method:
    // Try to load additional jar files in background by loading a class from each jar file.
    Thread loadClass = new Thread() {
      public void run() {
        System.out.println("Loading classes...");
        try {
          // Tried loading classes this way, doesn't work.
          getClass().getClassLoader().loadClass("pkg1.Class1");
          getClass().getClassLoader().loadClass("pkg2.Class2");
          getClass().getClassLoader().loadClass("pkg3.Class4");
          getClass().getClassLoader().loadClass("pkg4.Class4");
          /* Loading classes this way doesn't work either.
          Class.forName("pkg1.Class1");
          Class.forName("pkg2.Class2");
          Class.forName("pkg3.Class3");
          Class.forName("pkg4.Class4");
        catch(ClassNotFoundException e) {
          // First attempt to load a class (pkg1.Class1) throws exception.
          System.out.println("Can't find class: " + e.getMessage());
    loadClass.start();As you can see from above I am trying to load a class from each of the jar files so that the jar files would load into memory/cache. Unfortunately, it cannot find the classes. These are the errors from the java console:
    Loading classes...
    Loading: pkg1.Class1
    Connecting http://my.server.com/my_dir/pkg1/Class1.class with no proxy
    Connecting http://my.server.com/my_dir/pkg1/Class1.class with cookie "JSESSIONID=some_big_long_char_list"
    Can't find class: pkg1.Class1
    So it appears the jar file is not being downloaded. When I take away the dynamic jar loading (removing the "jar -i" & adding them all to the applet archive list) the thread executes correctly. So I know the class names, etc, are correct. How does one load an applet jar file?
    Any help/suggestions are appreciated.

    The above error I posted was because I forgot to index the jar files. That is why it couldn't find the jar file. I thought I was getting farther along with my problem, but I apparently just forgot to index the jars. I am now getting the problem that I got yesterday...
    The applet freezes/hangs when it hits the thread. The GUI never opens (even though I'm running this thread right after the gui shows). The java console quits responding and the applet just stays the grey screen. I also tried the invoke later that you suggested.
    public void start() {
      // ...initialize gui...
      // Applet freezes and remains grey, also the java console freezes.
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          System.out.println("Loading classes...");
          try {
            // When I comment out the below forName calls, the thread will still run evidenced through the done print statement.
            Class.forName("pkg1.Class1");
         Class.forName("pkg2.Class2");
         Class.forName("pkg3.Class3");
         Class.forName("pkg4.Class4");
            System.out.println("...Done loading classes");
          catch(Exception e)     {
            System.out.println("Can't find class: " + e.getMessage());
    }

  • Question about Java Applet Jar file signing.

    These questions pertain to Java 6 Standard Edition 1.6.0_22-b04 and later.
    I have gone through the Oracle Java Tutorial for generate public and private key information
    to sign a jar file, and how to sign the jar itself, all at
    [http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html]
    , and seek some clarification on the following related questions:
    -In order to "escape" the java applet sandbox that exists around the client's
    copy of the applet running in their web browser, ie.
    (something forbidden by default), is verification of the signed applet enough, or is a policy file required
    to stipulate these details?
    -using the policytool policy file generator, what do I need to add under "Principals"
    (if anything) when dealing with a Java applet? Are Codebase and SignedBy simply author information?
    -If I choose to use a java.security.Permission subclass object set up in equivalent fashion within the Applet,
    which class within the Applet jar do I instantiate that object in? Does it need to be mentioned
    in the applet's jar Manifest.MF file?
    -Is the "keystore database" a java language service/process which runs in
    the Server's memory and is simply accessed and started by default
    by the client verifier program (appletview/web browser)?
    -The public key certificate file (*.cer) is put in the webserver directory holding
    the Applet jar file (ie. Apache Tomcat, for example).
    -Presumably, the web browser detects the signed jar
    and certificate file, and provides the browser pop up menu asking the user
    about a new, non recognised certificate (initially).
    Is this so?
    -With this being the case, can the applet now escape
    the sandbox, be it with or without the stipulated
    policy permissions?

    848439 wrote:
    -In order to "escape" the java applet sandbox that exists around the client's
    copy of the applet running in their web browser, ie.
    (something forbidden by default), is verification of the signed applet enough, or is a policy file required
    to stipulate these details?Just sign the applet, the policy file is not necessary.
    -Is the "keystore database" a java language service/process which runs in
    the Server's memory and is simply accessed and started by default
    by the client verifier program (appletview/web browser)?No.
    -The public key certificate file (*.cer) is put in the webserver directory holding
    the Applet jar file (ie. Apache Tomcat, for example).No. For a signed Jar, all the information is contained inside the Jar.
    -Presumably, the web browser detects the signed jar
    and certificate file, and provides the browser pop up menu asking the user
    about a new, non recognised certificate (initially).
    Is this so?No. It is the JVM that determines when to pop the confirmation dialog.
    -With this being the case, can the applet now escape
    the sandbox, ..Assuming the end-user OK's the trust prompt, yes.
    ..be it with or without the stipulated
    policy permissions?Huh?

  • Java applet security file.list()

    I am trying to read the directory structure from a signed applet. I
    have created the applet and provided it with the
    UniversalFileAccess. I am able to read a specific file, and see all
    the contents of the file. I am wanting to performa simple
    directory listing vie the following code.
    My browser is Communictor 4.76 on Win 2000.
    blah.. blah...
    if(browser.indexOf("netscape") >= 0){
    //Assert Netscape permissions
    try{
    // tried UniversalFileRead, UniversalFileAccess,
    UniversalPropertyWrite,
    PrivilegeManager.enablePrivilege("UniversalFileRead");
    System.out.println("Netscape now has UniversalFileRead
    privilege.");
    } catch (netscape.security.ForbiddenTargetException e1) {
    System.out.println("Permission to read file system denied by
    user.");
    e1.printStackTrace();
    } catch(Throwable e){
    System.out.println("Could not enable privilege." +
    e.getMessage());
    e.printStackTrace();
    try {
    File f = new File("c:\\temp\\");
    String [] fileList = a.list();
    } catch (Throwable e) {
    System.out.println("File List failed");
    e.printStackTrace();
    I keep getting a secuity exception that I do not have priveledes to
    perform this action.
    Can anyone help!!!!!!!! I am on a deadline, and this is working just
    fine with IE.
    Please reply directly to me, as this is the first time I've ever posted
    to this newsgroup. My email is [email protected]
    Thanks,
    James Kurfees

    This question has been asked many times in these forums.
    There is no way to prevent this from a determined reverse engineer.
    Search for java obfuscators, which can help a little bit.
    The only way to prevent code stealing is to run it on your own server,
    which means not to use applets, but servlets/JSP. I am sure this is
    not what you want to hear.

  • Applet save file!! URGENT!!!!!!!!!

    How do i make an applet display a file dialog and save a file to a client's machine? I am using robot to capture the applet screen and want to save this image.... I keep getting accesscontrolexception and have read a lot of articles about signing applets, but nothing seems to work. Please help!

    Hey,
    Sorry about the title.
    Anyway here is the problem:
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.security.*;
    public class SaveFile extends Applet{
         public void init(){
              FileDialog dialog = new FileDialog(new Frame());
              dialog.setMode(FileDialog.SAVE);
              dialog.show();
              String fn = dialog.getFile();
              if(fn != null){
                   final File file = new File(fn);
                   FileWriter fw = null;
                   try{
                        fw = (FileWriter) AccessController.doPrivileged(
                             new PrivilegedExceptionAction() {
                                  public Object run() throws Exception {
                                       return new FileWriter(file);
                        //fw = new FileWriter(file);
                        fw.write("This is a test");
                        fw.close();
                   }catch(Exception e){
                        //System.out.println("Exception -> " + e);
                        e.printStackTrace();
    This is the exception that i get when running this applet.
    java.security.AccessControlException: access denied (java.io.FilePermission test.txt write)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkWrite(Unknown Source)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at java.io.FileWriter.<init>(Unknown Source)
         at SaveFile$1.run(SaveFile.java:20)
         at java.security.AccessController.doPrivileged(Native Method)
         at SaveFile.init(SaveFile.java:17)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    I am running this on my server (localhost). If i go into the policy tool and grant all permissions, it works fine but only on this machine and not over the web. This file is supposed to run over a SSL site hosted by IIS. I set up SSL within IIS, but I dont know why I should request another certificate just for signing an applet.

Maybe you are looking for

  • Why won't Photoshop Elements 11 and Premier Elements 11 load ?

    I just purchased Photoshop Elements 11 and Premier Elements 11.  I have Windows 7pro, have the disc for Windows and have the serial numbers for both programs.  When I put the disc in, I can't get past the welcome screen.  Why?

  • How Do You Create Subdirectories?

    Hello, I want to design my website with subdirectories, but do not know how to do it. For example, for my photo pages, I would like to individually list each year from 2001 to 2007 on one page (such as a welcome page) and then under each year have pa

  • Install and test of Adobe Air on Mac OS X did not go well

    I downloaded and installed Adobe Air onto my Mac OS X 10.5.5 machine. I then downloaded about six different Adobe Air apps, and tried to start each one in the usual way (double clicking on them). The error message I got in each case is the following:

  • Slideshows in aperture

    unable to save for export slide shows??? How do I??

  • UCCX Script String Substring Function

    I cannot use the Substring function to obtain a specific value from a string variable. My substring position is variable, so I need to put a variable, loop and increment it the position. When I try to add the below command, this is getting the error