Applet read/write files

Hi,
I have a problem to use getCodeBase to get the URL. Actually, I am pretty confused on running the applet in our intranet.
Let me explain my problem here, I have mapped a network drive(G:\personA) in my machine and my applet and all the files are in G:\personA\classes. In my coding, I have tried to specify my files paths such as G:\personA\classes\index.txt and I can run the applet without any problem either with Eclipse or from a web site http://personA//report.html. But the other members in this company cannot run this applet thro' this web site( http://personA//report.html). The problem is "No class found", can't find the path G:\personA\classes\index.txt.
So I decided to change my code by reading/writing files thro URL i,e : http://personA/classes, but when I run my applet, I got the following exception :
ava.lang.NullPointerException
     at java.applet.Applet.getCodeBase(Applet.java:136)
     at web.MyChart.readAndPrintData(MyChart.java:336)
     at web.MyChart<init>(MyChart.java:113)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
     at java.lang.Class.newInstance0(Class.java:308)
     at java.lang.Class.newInstance(Class.java:261)
     at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
     at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
     at sun.applet.AppletPanel.run(AppletPanel.java:298)
     at java.lang.Thread.run(Thread.java:534)
does anybody knows how to solve this problem?? Please...
Thanks,
Tiffany

I think a trace would help, guessing is fun but won't solve your problem:
To turn the full trace on (windows) you can start the java console, to be found here:
C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
In the advanced tab you can fill in something for runtime parameters fill in this:
-Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
if you cannot start the java console check here:
C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
I think for linux this is somewhere in youruserdir/java (hidden directory)
add or change the following line:
javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
for 1.5:
deployment.javapi.jre.1.5.0.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
The trace is here:
C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
I think for linux this is somewhere in youruserdir/java (hidden directory)

Similar Messages

  • Applet to write file on IE4.0

    Hi all,
    Please help, the situation is like this,
    server has no support for web, no Java plugin...
    client browsers' are equipped only with IE4.0, and they will not be upgraded nor plugged with Java Plug-in.
    On these strict circumstances, how could i run an applet to read/write files?
    if the applet is converted to an application, file permission problem should be solved, but how could the clients run the CLASS/JAR files without installing JRE...
    pls help, it's in ergent. (have to finish the program in this week!!)
    Thank you a million!!!!!!
    J.

    New foundings!
    As the server is running Netware 4.2, is that possible if i just install JVM on the server and problem will be solved?
    J.

  • 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 !!!

  • How to read write file in HTML5 extension

    Hi,
    I think it could be very generic question since moving from Flex to HTML5 extension is loosing ability to read write a file in local file system.
    I'm trying to write a log file within extension space but It throws error as 'TypeError: Illegal constructor'
    new File(csInterface.getSystemPath(SystemPath.EXTENSION)+"/log/Log_"+.getCurrentDateString+".txt");
    does someone have solve for this.
    Thanks in advance
    MM

    Yeah, It could be a reason for nested error but I got the error right before executing "getCurrentDateString". But I kind of figured it out as Javascript looses ability to read write file in user file system except Crome browser, you can read more here. However Adobe has added fs API within CEP which allows user to read and write file in user system.
    Here is some peace of code on how to do it, complete API reference check here :
    var result = window.cep.fs.writeFile(logFilepath, "Your data goes here");
      if(result.err != 0)
      throw new Error("Result object has error");
    However still this does not provide any method to append the content in existing file as a result if you wanted to write kind of log file, every time you need to first read the file and then concatenate your content to file data then write data again to new file. sound hefty to append content?
    I'm hoping if any Adobe staff has any comment on this.
    Thanks
    MM

  • IO Operation (read/write files) in IPAD AIR downgrade ~50% than the one in IPAD4

    Summary:
    UnZip the same file with the same native unzip method (native zlib) in IOS7, ipad air take +50% more time consumption than the one in iPAD4.
    for unZip, it main perform the IO read/write files in ipad, does apple air already changes the file system ?
    Steps to Reproduce:
    UnZIP a file with native zlip on both ipad AIR and IPAD 4 :
    IPAD AIR: 16GB
    IPAD 4: 16GB
    ZIP file size: 700KB
    Files in zip file: 225 files (120 files are images)
      after remove the images, the time on IPAD AIR will save 50% time consumption
    unZip method: the native zlib
    unzip time on IPAD AIR+ IOS7: ~1200ms
    unzip time on IPAD 4+ IOS7: ~800ms
    Expected Results:
    The unzip time should be almost the same on IPAD AIR and IPAD4.
    Actual Results:
    For same IO operation read/write file, IPAD AIR gets the 50% downgrade performance than the one in IPAD4
    Version:
    IPAD4: 16GB WIFI + IOS7
    IPAD AIR: 16GB WIFI + IOS7
    does anyone else encounter the same problem ?
    A bug already submitted for apple: https://devforums.apple.com/message/993060

    I even tried porting the code to Gumbo and running it there - still, no fonts are being enumerated.
    If you're too lazy to read the whole above post, here's the problem in one sentence
    An SWF that contains a textfield with embedded fonts, when launched by itself succeeds to return the embedded font using Font.enumerateFonts(false), however when loaded using Loader.loadBytes into AIR, it fails to see those fonts even though the textfield in it is displayed and editable.
    How do I make the loaded child application and AIR see the embedded font?

  • Help with Read/Write File

    hi I was wondering if someone can help me do some read/write file with java. here is what I want to do:
    Read a file and search the whole file for a word such as "throw" and print out the rest of that line to a new file. in the case of "throw", i want to link all thrown exceptions to the file that contained them.
    can someone help me out and let me know what way I can approach in this?
    any help would be greatly appreciated.
    thanks!

    Rough and dirty, here's a class that will read a file and return a resultset:
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.FileChannel;
    import java.util.*;
    import java.text.DateFormat;
    public class Utils{
         File fileName;
         FileOutputStream outputFile;
         boolean closeChannel;
         //Constructor
         public Utils(String directory, String filename){
              String strFileDir = directory;
              String strFileName = filename;          
              File fileDir = new File(strFileDir);
              fileName = new File(fileDir, strFileName);
              // If directory does not exhist, create it.
              if(!fileDir.isDirectory()){
                   if(fileDir.mkdirs()){
                        System.out.println(fileDir + " created.");
                   else{
                        System.out.println(fileDir + " could not be created.");                    
    public ArrayList readText() throws IOException{          
              // Read content of file into a collection
              ArrayList arrayList = new ArrayList();
              try{
                   BufferedReader in = new BufferedReader(new FileReader(fileName));
                   String line;
                   while((line = in.readLine()) != null){
                        arrayList.add(line);
                   in.close();               
              catch (IOException ex){
                   throw ex;
              return arrayList;          
         }And here's how you use the class:
    // Create a new Disk Utilities object.  This can be used for all subsequent read/writes to this file.
              Utils utilTest = new Utils("e:/testing", "Testing.txt");
    // Create a collection to hold the data from the file.
              ArrayList arrayList = new ArrayList();
              try{arrayList = utilTest.readText();}catch(IOException ex){ex.printStackTrace(System.err);}

  • How To read/write file on remote server in java

    Hi All,
    How To read/write file on remote server in java? I mean using URL - http://www.xyz.com can I right file to that perticular server.
    Thanks in advance

    If your server support a means of uploading files you can.
    A popular means is [http://en.wikipedia.org/wiki/WebDAV]
    However, by default web server don't allow you upload files, its usually something you need to configure or install.
    I suggest you have a look at your web servers documentation.

  • How to sign MIDlet so it wont confirm before read/write file operation ?

    hi there,
    i am developing application which reads mp3 files from the songs folder. but at each run of my application it ask the confirmation to Allow to read and write file to application.
    how can i othorize or sign my MIDlet to overcome this problem ?
    i m using Sony Z550i phone.

    on some J2ME platforms you may have to sign the applet to set the option to Always Allow.
    Under NetBeans all you have to do to sign the app is go to the Projects window, right click on the desired project, select Properties. A Project Properties window will pop-up. On the left hand side, near the bottom, select Signing. Select the check box labeled 'Sign Distribution'. By default there is a 'built-in keystore' that should work with many J2ME platforms but you can also generate your own keystores through the Security Manager.
    If you wish to generate your own keys:
    WARNING: may not work with all J2ME platforms if you are not able to authorize the key on the platform you wish to run it on.
    Beside the 'Sign Distribution' checkbox there is a button labeled 'Open Security Manager'. There you click 'Add Keystore'. Fill in a password and it will create your keystore. Next, select the newly generated keystore and click the 'New' button to add keys to the keystore. Simply fill out the form and it will generate a key for you.
    When you build using NetBeans it may ask you for the keystore and signing key passwords again, so make sure you use a password you will remember.

  • Help with utl_file (read/write file from local directory)

    Need help reading/writing file on local machine from plsql using 10.2 DB.
    I am trying to read/write a file from a local directory(laptop) without success.
    I have been able to read/write to the database server directory but can't write to directory on local machine.
    The utl_file_dir parm has been set to * and the db restarted but I can't get it to work... Here's the plsql statement.
    out_file := UTL_FILE.FOPEN ( 'C:\PLSQL', 'TEST.TXT', 'W' ,32767);
    Whenever I run it continues to write to c:\PLSQL dir on the database server. Have looked at the "Directory" object and created MY_DIR = C:\PLSQL but it writes to the db server.
    Running 10.2 on a remote windows server, running PLSQL using sql*navigator.
    Thanks in advance for your help..

    I don't see how you expect the server to be able to see your laptop across the network, hack into it and start writing files. Even if it could, what if there is more than one laptop with a C: drive? How would it know which one to write to?
    Is there a shared drive on the server you can access via the laptop?

  • Read/Write file in Unicode (UTF-16)

    Hi, I have some issue to write a file in Unicode (UTF-16)
    I have to read a file with LabView, change some parameters and write the new data into the same file. The file uses Unicode UTF-16.
    I downloaded some library here: https://decibel.ni.com/content/docs/DOC-10153
    I can read the file, convert the data to UNI/ASCII/UNI, and then write the file. But when I open the new file with an editor like Notepad++ there are some unexpected characters at the end of the line.
    Even reading the file and writing exactly the same data doesn'not work.
    I attached an example.
    Thanks for you kind support.
    Solved!
    Go to Solution.
    Attachments:
    TEST.zip ‏7 KB

    Right-click on your Read and Write Text File functions.  There is an option to "Convert End Of Line".  Turn that off on both functions.
    As a side not, you don't need the Close File functions.  The Read and Write Text File functions will close the file if the file reference output is not wired.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Applet read/write to drive?

    I'm considering learing java to create a applet that people can use while playing a game. I read somewhere that applets can't normally read/write to a drive. Is this true? How could the information the users put in be saved on their side for future use? Do I have to go with C++?

    Your answer is "yes, but".
    Your applet can access the user's drive if you "sign" it. You may already have found that out in your research. What that means is, the first time the user loads your applet, a dialog box will come up asking the user if they want to allow your applet to do that.
    This may cause the user to become suspicious, especially in these days where worms and viruses are on the front page of the newspaper. However if your users are your friends and acquaintances -- or have some other reason to trust you -- then that may not be a problem.

  • Applets : reading other files (AccessControlException workaround)

    i hava an applet which should read some files located in a subdirectory of the applet root and which are handled as RandomAccessFile, but applets don't have permissions to read these files.
    is there a workaround ?

    ONE SOLUTION IS THAT YOU SIGN THE APPLET
    SECOND USE THE URL CLASS TO ACCESS THE FILE

  • How to read, write file inside the JAR file?

    Hi all,
    I want to read the file inside the jar file, use following method:
    File file = new File("filename");
    It works if not in JAR file, but it doesn't work if it's in a JAR file.
    I found someone had the same problem, but no reply.
    http://forum.java.sun.com/thread.jsp?forum=22&thread=180618
    Can you help me ? I have tried this for all night !
    Thanks in advance
    Leo

    If you want to read a file from the JAR file that the
    application is packaged in (rather than a separate
    external JAR file) you do it like this ...
    InputStream is =
    ClassLoader.getSystemResourceAsStream("filename");Better to use
    this.getClass().getClassLoader().getResourceAsStream();
    From a class near to where the data is. This deals with multiple classloaders properly.

  • Read/write file located on server

    Hi,
    I want to read a TXT file located on server and depending on the response I want to write an XML file also located on server
    how could be it possible in JAVA
    please help me
    alpesh

    the TXT file is located on the WEB server, and I want
    to read the TXT file's content From the client, I assume. URLConnection. Or your favorite browser.
    the content is the User InformationAnd you want to write that on the server. Forget it, unless you have CGI or FTP or a servlet or whetever to process incoming requests or allows you to connect to the fie system somehow (WebDAV).

  • Read/Write file

    Can anyone tell me how can I read a text file and then write it back after some modifications?

    Hi,
    Check this out.
    http://java.sun.com/docs/books/tutorial/essential/io/filestreams.html

Maybe you are looking for

  • OIM11g: Is there a way to find out what method is used to create user

    Hello, I have a user pre-create event handler that gets called every time a user is created in OIM. In here, is there any way to find out if the user is created by self-service request, admin, or by an external client that used UserManager API? How c

  • MacBook Pro (13") Trackpad

    Hi. When I bought my MacBoo Pro 3 weeks ago, the trackpad was working fine. But, it doesn't let me do a double-click if i use the bottom left corner. It does eventually work if I keep on clicking it, but it feels as if its sticking? Does anyone know

  • HP3600 Laserjet - Config via Hostname not working

    I have been down this road (all day), but you did point out something I did not realize.  I am using the hostname to configure the printer, and I get through the process.  When I print, I get "Error - Printing" which we all no is a totaly useless mes

  • Downloading dynamic data without a server roundtrip?

    Is there a way to get a FileReference.download like experience for dynamic data? I've tried feeding a data: url into download, which seemingly triggered a bug as I got a save dialog and a true return value from download(), but no data was ever saved.

  • JHeadstart inputtext blocks my javascript

    I've put some javascript in a page wich works just fine in firefox (see thread 'Move to the next inputtext with the ENTER key instead of TAB' in Jdeveloper forum). The problem is that it doesn't work in IE. The folowing code is the problem (without i