DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Applet reading text file on client machine, possible?

  1. #1
    Charlie Flynn Guest

    Applet reading text file on client machine, possible?


    Is it possible to get an applet to read a text file on a client machine?

    Title Description:

    A background process on the client's desktop is generating numbers and writing
    these to a text file. I want an applet to display different colours based
    on these numbers. This text file will be updated on a per second basis and
    the applet must respond in real time to these updates. For purposes of demonstration,
    I am the user. Do I need to grant the applet any extra privileges to read
    from the text file and how do I do this as the applet programmer?

    o If it is not possible to read from a text file, is there any other way
    I can send the applet these numbers, for example as parameters to some function?

    Alternative 1:
    I want to have access to mouse co-ordinates both within and outside of the
    applet. I have been using the mouseDragged method. Once a drag is performed
    inside the applet the applet can continue to read co-ordinates of the motion
    outside the canvas frame provided the mouse button remains depressed. I
    want to be able to do this without enforcing drag. Is it possible to write
    a method that
    Mouse motion within the browser affects a small coloured window that is a
    second applet. The applet receiving the co-ordinates from the mouse motion
    will appear as a second window within the browser changing colour based on
    these co-ordinates. My aim is to have the applet registering motions should
    have as little graphic impact on the html page as possible, in other words,
    the users should be unaware of its presence.

    Alternative 2:
    Is it possible to create a transparent applet that can sit over the html
    page so that all mouse movements are contained within the applet canvas -
    but the applet has no graphic impact on the page?

    Alternative 3:
    If it is not possible to read from the file on a client machine, can I get
    the client to send a text file to the server and get the server to process
    the numbers and sent them back to the client for display in an applet on
    the client machine?

    ========================================================================================== ========

    For the same coloured screen I need to write a second similar program that
    changes colour based on network traffic or cpu load instead of mouse motion.
    What java API would I need to use for this? Or what is the best way to
    begin to approach this? P.S. I am using windows 98 for my clients and server.

    Many Thanks,
    Charlie Flynn.

  2. #2
    Steve Giergiel Guest

    Re: Applet reading text file on client machine, possible?


    I am fairly new to java, but am experimenting with XML and java and came
    across your problem in an exercise.

    I am not quite sure how you would do this programmatically, but in JDK 1.3
    there is something called


    which you run from command line and effectively register the code that needs
    to access what, assigning the required privileges.

    I suspect that in practise you probably need to use Digital Certificates
    and allow the user him/herself to grant the necessary privileges based on
    trust of the software developer/supplier. However I am not up to Digital
    Certificates in java yet.

    If you get to work out how to do all this programatically , please let me
    know, as I would be very interested to learn how to do this.


  3. #3
    Lynn Guest

    Re: Applet reading text file on client machine, possible?

    You have to open the java.policy file (found in the security folder wherever
    the JDK was installed) to edit the permissions.

    Select the Codebase <ALL> policy entry.

    Click on Edit Policy Entry.

    Either edit a permission (depending on whether it exists) or add a new one
    for what you need to do. For example, if you receive a socket permission
    from the applet to the servlet, the Actions need to have "accept, connect,
    listen, resolve".


  4. #4
    Lynn Guest

    Re: Applet reading text file on client machine, possible?

    Oh, by the way, to be able to read a file on the client machine, your applet
    has to be 'trusted', that is, behave like a normal application.

    A book that I used for applet/servlet communication is "JAVA Servlet Programming"
    by Jason Hunter (O'Reilly). You can go to and view sample
    code from the chapters.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center