Reputation: 3334
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
Upvotes: 3
Views: 11306
Reputation: 21
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.
Upvotes: 2
Reputation: 861
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());
Upvotes: 0
Reputation: 6190
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:
Upvotes: 3