Is there a code, I can use that will (once I run it), physically open the cd/dvd drive? I know this is possible in some other languages, but is it possible in Java? Please point me in the correct direction. Thank you
Asked
Active
Viewed 1.1k times
3
-
[previously][1] [1]: http://stackoverflow.com/questions/5813876/eject-cd-using-java – ObscureRobot Oct 19 '11 at 22:46
-
3Any particular platform? (The answer's generally "no, but you can make Java execute [appropriate command for ejecting drive on platform X]"). – John Flatness Oct 19 '11 at 22:54
-
@JohnFlatness I'm looking for a solution on the windows platform. – Jeel Shah Feb 23 '13 at 17:56
3 Answers
3
Java provides no way to interact with a cd drive. One easy way on the Windows plateform is to call a VBS script.
Few links which might help you:

Ritesh Mengji
- 6,000
- 9
- 30
- 46
2
The code to open a CD drive can be even simpler than meain's answer. The .exe file does not need to be copied. It can be run from a command line inside the program :
Runtime.getRuntime().exec("nircmd cdrom open d:");
It should execute and find the nircmd.exe
file automatically in the system bin.
0
Check out ninrcmd. It an exe file and has a built in function to open the CD drive.
nircmd.exe cdrom open j:
and to close it
nircmd.exe cdrom close j:
To use it add the exe into your program and use this code
Runtime.getRuntime().exec(this.getClass().getResource("nircmd.exe cdrom open j").getPath());

meain
- 833
- 9
- 28