Java - Disk Reader (Linux)

Asked

Viewed 40 times

2

Good night,

I was looking like we can open the disk drive on Windows using Java there are various means like even using vbs.

I wonder if I need to use some library on Linux or if I can do it directly by some command.

Could someone direct me? Thank you!

  • Try calling the terminal and executing the command to eject Runtime run = Runtime.getRuntime(); run.exec("eject -T");

1 answer

2


To open the drive:

try {
  Runtime.getRuntime().exec("eject cdrom");
} catch (Exception e) {
  System.out.print(e);
}

To close the drive:

try {
  Runtime.getRuntime().exec("eject -t cdrom");
} catch (Exception e) {
  System.out.print(e);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.