Using files from an applet

Hello !
I know it is impossible to write files from an applet for security reasons, but I "only" need to read some data from files.
My applet works perfectly with the appletviewer, but when I try from IExplorer, it reacts as if the files were missing. In fact, I think it is a poblem with the location...where could I find the files ? What path do I have to mention in my code ?
I tried to use a .jar archive, putting all my .class and data files in that archive, but it still doesn't find the data files.
Thanks for you help.
C14

There's just as much security about reading files from an applet, otherwise a hidden applet on a web page could read the files on your PC and transmit your secrets to some web site.
You [i[can[/i] write applets to read (and write) files on the local machine but they need to be digitally signed.
If the files you want to read are just parameters etc. then the best thing is to put them where you put your html and read them through a URL connection. That's allowed.

Similar Messages

  • How do I update a file in an Applet's JAR file from the Applet code

    Here's my problem.
    My applet is using a serializable history data in which I am storing in the applet's JAR file. When I run the applet, I read the file with "getResourceAsStream()" and run my program with that hist data. When my applet is closed, I need to update this file from my Applet's code and I dumfounded about how to do that.
    Is there any way to update a file in the Applet's JAR file through the Java Applet code? (i.e. OutputStream?).
    Would appreciate any advice people have.

    Just place a copy of the file on the local hard disk and update that. When you start the Applet you try to read from the hard disk. If the file exists then no problem otherwise copy it from the jar to the hard disk.

  • Reading and writing to a text file from an Applet

    I'm a novice java programming with very little formal programming training. I've pieced together enough knowledge to do what I've wanted to do so far...
    However, I've been unable to figure out how to read and write to a text file from an Applet (I can do it from a normal java program just fine). Here is a simple example of what I'd like to do (you can also look at it on my website: www.stat.colostate.edu/~leach/test02/test02.html). I know that there is some problem with permission/security but I'm not smart enough to understand what the error messages are telling or understand the few books I have. If anyone can tell me how to get this applet to work, or direct me to some referrences that would help me out I'd really appreciate it.
    Thanks,
    Andy
    import java.applet.Applet;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    public class test02 extends Applet {
    public Button B_go;
    public GridBagConstraints c;
    public void init() {
    this.setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    B_go = new Button("GO");
    c.gridx=1; c.gridy=0; c.gridwidth=1; c.gridheight=1;
    c.weightx = c.weighty = 0.0;
    B_go.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    print_stuff();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.add(B_go,c);
    public static void print_stuff() {
    try{
    File f = new File("test02.txt");
    PrintWriter out = new PrintWriter(new FileWriter(f));
    out.print("This is test02.txt");
    out.close();
    }catch(IOException e){**/}
    }

    I have almost the exact same problem, and I am in the same situation as you are with respects to the language.
    I am simply trying to create a file and output some garbage to it but my applet always spits back a security violation. I've tried eliminating the restrictions on the applet runner I use but I still get the error.
    My method:
    debug = new Label() ;
    debug.setLocation( 20, 20 ) ;
    debug.setSize( 500, 15 ) ;
    add( debug ) ;
    // output
    try
         OutputStream file = new FileOutputStream( new File( "" + getCodeBase() + "output.txt" ) ) ;
         byte[] buffer = { 1, 2, 3, 4, 5 } ;
         file.write( buffer ) ;
         file.close() ;
    } catch( Exception e )
         debug.setText( e.toString() ) ;
         Can anyone tell why this isnt working?

  • How to use DOMParser from an Applet / Or, how to parse XML from an Applet?

    Hey,
    As stating in the subject line, I wonder how to do it without getting an �Access Denied� error.
    I would like to parse a XML file that has external DTD pointing to a SYSTEM location. Yes, I can change it to a public location. However, in either way, I have problems to use DOMBuilder to parse the xml file. The application always throws the security exception.
    I tried to use the DOMParser from org.apache.xerces.parsers to parse the xml file. I set the DOMParser to ignore parsing the external DTD, and use the DOMParser.parse(InputSource) to parse the xml file from a giving URL. However, I get null of the result document.
    Does anyone know how to parse the XML from an Applet? Or, does anyone know how to use the DOMParser from an Applet?
    Thank you very much,

    If the document resides on the local filesystem, you will need to sign a CAB or JAR for the applet to circumvent the sandbox's security restrictions. There are dozens of posts on how to do this. Basically, that will turn the applet into an application, from a Java security perspective.
    - Saish
    "My karma ran over your dogma." - Anon

  • Using POST from an applet

    Hi,
    I need to connect to a URL from my applet and have the results show up in a new browser window. I have to use POST method since I need to submit a lot of parameters with the request. If I could have used GET method instead, this could have easily been accomplished using showDocument method. Even though applets can connect to a URL using POST, I could not locate any information on how to display the results in a new browser window. Anyone know how this can be accomplished?

    To POST data to servlet :
    - get data in applet by using getText() or getSelectedItem ...
    - Open connection by URL class
    - Open outputStream by BufferedWriter class
    - Using write(String) to write data then close the tream
    - to Receive data from servlet : getInputStream by BufferedReader class and then using readLine() to read data .
    - Notice : you must make a protocol for your Applet and Servlet able to interface with it other
    Good luck !

  • Using JDBC from an Applet

    Hi,
    I'm trying to connet to an Oracle database from an Applet, using the oracle jdbc thin driver.
    When I'm running the applet with the applet viewer I can connet to the database. But, when I view the applet with Internet explorer 6 with the Microsoft JVM I get an exception:
    Error loading class: oracle.jdbc.driver.OracleDriver
    java.lang.NoClassDefFoundError
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
         at com/ms/vm/loader/URLClassLoader.loadClass(URLClassLoader.java)
         at java/lang/ClassLoader.loadClassInternal (ClassLoader.java)
         at java/lang/Class.forName (Class.java)
         at MyApplet.<init> (MyApplet.java:25)
         at com/ms/applet/BrowserAppletFrame.newInstance (BrowserAppletFrame.java)
         at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
         at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
         at com/ms/applet/AppletPanel.run (AppletPanel.java)
         at java/lang/Thread.run (Thread.java)
    I've tried to:
    1) Put the driver jar in the same place as the applet
    2) expand the jar in the applet's folder
    2) Add the jar to the archive attribute of the APPLET tag
    3) Add the applet and the content of the jar to a single arhcive
    but so far far nothing helped.
    Thanks,
    Dror B

    Hi,
    Did you try to use Sun's JVM? Microsoft VM is old, and probably does not contain the classes required by Oracle's driver; besides, it supports only old class format, which has evolved in Sun's JVM.
    Another solution is to use the RMI-JDBC driver by http://objectweb.org.
    Sincerely,
    Sergei Batiuk.

  • Read, Write and create files from java applet.

    Dear All,
    I have created a two files. One is applet and one application file. I am creating a instance of application file in applet. Application file is used for reading, writing and creating files. When I invoke applet from broser it dipslays error wrt file access permission. From the forum search I know that we need to sign the applet / edit the java policy to run the code locally. Final delivery of my code should execute on different system. Its not web. I have created a html page on submitting the form it invokes applet to read the form values from param and needs to update the values in xml file located locally. Please help me on how I can proceed with this fix.
    Thanks in advance.

    Sorry if I have not stated the problem clearly. I need to update content to files hosted in local system using java applets.
    I belive there are two ways to achive that.One with jar signer and one with modifying the java policy file. But this application needs to be installed in different system locally as I have created a application with webpage as useinterface and need to update the content in local files on submission. Not sure on how to modify the java.policy files in each end user system and whats the value we need to update in java policy file. Please help me on the steps to be followed

  • Recover & use files from crashed TM harddrive

    Hi all,
    Here's the case.
    I switched from a 24" iMac with 10.6 to a 27" iMac with 10.6
    During this switch, my only source of backup was a 500GB WD with TimeMachine.
    When i plugged this drive into the new iMac, it said the disk was "unformatted", even though I used it the day before to do the final backup.
    So here I stand with everything I own datawise lost. I can see the partition containing folders using AppleXsoft File Recovery.
    The question: Can I somehow recover these files in their folders, and rebuild them to a hardrive so that the computer will recognise it as a TM-backup?
    Any help appreciated!
    Alex

    V.K. ("the guru" here) is, of course, correct.
    Time Machine does incremental backups of new and changed items since the previous backup, but each backup is, in effect, a full one.
    This "magic" is done by linking to the backups of the items that did not change with "hard links." An item that was present on your Mac for two or more backups will have multiple hard links to it's backup copies. This structure is used not only at the file level, but also at the directory level.
    Prior to Leopard, even OSX did not support doing this at the directory level; and even the Leopard Finder couldn't copy good backups properly, much less corrupted or partial ones.
    A data recovery app may be able to recover some of the backup files; but not the structure of links. At best, you're going to get a whole passel of "loose" files, with no structure whatever.
    For more details: http://www.appleinsider.com/articles/07/10/12/roadto_mac_os_x_leopard_timemachine.html
    and: http://arstechnica.com/apple/reviews/2007/10/mac-os-x-10-5.ars/14

  • Using files from dreamweaver 8 in CS5 - not working

    Hi All
    I made 2 websites a few years ago in Dreamweaver 8. We now have windows 7 at work so we are trialling CS5.
    Basically, i open up our web files (which were made in Dreamweaver 8) in CS5 and the site ios not being very friendly at all. It is almost like it doesn't recognise the codes and formats properly.
    And to change one line of text - i select and change colour - it changes the whole 3 paragraphs.
    Is Dreamweaver 8 files compatible with CS5.
    Need help
    one website is www.progressivegroup.com.au
    in the old version i could simply make changes with out any bit of hassel, in the new one i can barely do anything with out it going crazy on me!!
    Thanks

    Thank you for your help.
    Are the code errors from Dreamweaver 8?
    I am not the best with this sort of thing.
    How do i fix the errors so i can use the web siles in CS5?
    also, how do i validate the code?
    Thanks again

  • Using files from jtree as web application

    Hi frnds,
    My module is to create a tree in web page ,
    there we can add new node, rename the node, remove the node etc.
    I have done this using swing and integrated this tree in applet.
    It works fine as desktop application and web page level also.
    Now , I need to update the xml file upon adding/renaming/removing the node to tree.
    It's working fine when I run this applet as desktop/stand alone application.
    But The xml file is not updating when the new node added to tree in web page.
    Please suggest me the best way to solve it.
    I have taught to use web services or socket programming.Can I try in this way?
    Thanks,
    Anil Bandlamudi

    According to the article article posted on [http://www.informit.com/articles/article.aspx?p=26316&seqNum=7] there is no direct way of using an applet to write on a server file. Although it does mention about getting the functionality done by creating a daemon on server and communicating to it by opening a communication socket. See if this helps you. Good Luck.

  • Can I use files from a portable hard drive

    I have a project I need to edit
    All the files are HD and supplied on a portable USB3 hard drive.
    I can import them into final cut pro, but when I go and try to share the project or send it to compressor the options are all grey out?
    Do I need to save to files to my main hard drive or to a proper "powered" hard drive?
    I'm using most recent version of FCP on an iMac 27" running Yosemite...
    Thanks for your help in advance...

    Hello - okay the library files were on the external portable HD.
    After having no luck whatsoever with exporting the documents out, I tried moving just the files i needed to the main HD. But still I have no luck sharing anything, the menu items are still greyed out. The library is in the Movie folders in the user's folder
    Attatched is a screen shot as requested
    I hope this helps with an answer...
    Thank you...

  • Reading a data file from an Applet

    ...new to Applet Programming. I have a stand-alone application that converts
    an XML file to a DOM, then to a JTree. I have converted the application to an Applet
    But I can't find the trick to having the applet connect to the XML file.
    This is the line of code which works fine in the stand-alone, but hangs the Applet:
    document = builder.parse( new File( "P6B.Xml" ) );
    How can the applet read data located on the host in the same directory as the class?
    Sounds simple, but somehow can't find a way of doing this.
    One suggested solution (when the file is always needed) I have found browsing
    through this site is to wrap both the File and the Class in a JAR.
    In this instance, how can I parse the file?
    Appreciate any help.

    Give the complete URL of your xml file.

  • How to write into a file from an applet?

    Dear,
    I made an applet and I want to create a file in a machine. I tried many way but it not work.
    Here is the code:
    URL url = "http://hostname/filename.txt;
    URLConnection con = url.openConnection();
    OutputStream out = con.getOutputStream();
    out.write(data);
    out.flush();
    out.close();
    Please help me resolve it.
    Thanks.
    Khai

    URL url = new URL("http://hostname/filename.txt);
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(url.openStream()));
    out.write("data");

  • Call a method of a class file from an Applet

    I have an Applet nmaed CountDown.java in which I have to call a method "doSelect" of a class file named DBConnection.java. How do I do this? Both the Applet and the class file are in the same directory.

    You should put both classes in the same package and create a jar file containing the whole package.
    Make sure the DBConnection class is public or protected and that the method you're trying to call is public or protected.

  • Using Files from Nikon D4 Xqd card

    I'm having such problems just trying to edit images from my new NIkon D4 - LR3 won't even see them, and so I got the trial of LR 4 and it is so slow seeing them that it's barely usable. Are there any tricks that I'm missing?
    I'm using a quad core Mac Pro computer OSX.6.8 and LR4.0 trial.
    Lynne Harty

    Thanks Chuck - I've downloaded it and will give it a try. Right now I'm just filled with regret at having bought this camera. When I bought the Nikon D2x, D300 and D3s, I never had any of these issues. Seems like Nikon shouldn''t release products when the trade software isn't ready to handle them. Looks like I'll have to buy yet more software to deal with it - LR4, which otherwise I didn't need.

Maybe you are looking for

  • Unable to load DB2 library

    Hi, We are trying to install an application server on Windows in a UNIX SAP (abap+java) system with SAPinst.Our Central instance is in DB2/AIX platform and we want to install an windows application server. An error occured while processing start dial

  • Sales difference day-by-day until today

    Hi I have a keyfigure Sales Volume  in my cube... I have calculated keyfigure Sales Difference which is calculated as 'Sales Volume Present Day'-'Sales Volume Previous Day'...Sales volume present day and previous day are based on kefigure 'Sales Volu

  • Sync button not active??

    I'm new to CC. My sync button in lightroom is not active. I have a PC. What should I be doing?

  • 8520 won't connect to the computer

    when i plug the USB into the computer the phone starts charging so it obviously recognises it's plugged in but nothing happens on the computer! and when i click on my computer it says removable device but then says insert a device when you double cli

  • Help me uninstall cs4 from windows

    help me uninstall cs4 from windows I have cs5 and cannot open raw files thru bridge