Results 1 to 2 of 2
  1. #1
    prasad.vara is offline Member
    Join Date
    Jul 2010
    Location
    Hyderabad
    Posts
    21
    Rep Power
    0

    Default How to detect cdrom drive through Applet class

    Hi,
    I have a requirement that i want to detect the cdRom of a system. I implemented the code as below. It executed succcessfully when i implement the code in any java class. But when i implement that code in java Applet its not executing. please help me how to run that code in an Applet.

    public void start(){
    System.out.println("Start");
    java.util.Map map=new java.util.HashMap();
    java.io.File file[]=java.io.File.listRoots();
    System.out.println(file.length+"hi");
    for(int i=0;i<file.length;i++){
    if(file[i].canWrite()==false&&file[i].canRead()==true){
    System.out.println("Drive:"+file[i]+");
    map.put(file[i].hashCode(), file[i]);
    }
    }

    Thanks in advance,
    Prasad.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    its possible the sandbox that applets are ran in are by default preventing the File.listRoots() from working. Have you tried signing your applet? That usually enables some of these more privileged operations (even a self-signed certificate seems to work, the user is just prompted if they are sure they want to trust this application the first time they run it)

Similar Threads

  1. applet class inside java.applet.* or java.awt.*
    By Manish87 in forum Java Applets
    Replies: 1
    Last Post: 09-27-2010, 02:15 PM
  2. can Applet be an inner class?
    By zweibieren in forum Java Applets
    Replies: 0
    Last Post: 03-26-2010, 06:42 AM
  3. Best way to format a drive/thumb drive in java...
    By vandyke in forum Advanced Java
    Replies: 1
    Last Post: 12-09-2009, 01:32 AM
  4. Signed Java Applet to read a file on hard drive?
    By ollyworks in forum Java Applets
    Replies: 2
    Last Post: 09-11-2009, 10:08 PM
  5. Replies: 0
    Last Post: 02-26-2009, 03:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •