Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open CD-ROM Tray in Java

0 views
Skip to first unread message

B Meyer

unread,
Mar 26, 2001, 1:14:38 AM3/26/01
to
Hello everyone,

Does anyone know how to open the CD-ROM tray using Java? Is it possible to do
so, or must some sort of C code be used?


Thanks,
B. Meyer
Gran...@hotmail.com

_______________________________________________
Submitted via WebNewsReader of http://www.interbulletin.com

Gerhard Häring

unread,
Mar 26, 2001, 10:05:50 AM3/26/01
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 26 Mar 2001 06:14:38 +0000, B Meyer wrote:
>Hello everyone,
>
>Does anyone know how to open the CD-ROM tray using Java?

Yes.

>Is it possible to do
>so, or must some sort of C code be used?

Yes.

You can try to interface a command-line program that does this. The relevant
method is called System.exec or similar. On Linux, you can interface the
"eject" command line tool.

If no command-line tools exist for you platform that does this, you will need
to interface a system library that provides the function. JNI (Java Native
Interface) is the keyword here.

Gerhard

mail: gerhard <at> bigfoot <dot> de
web: http://highqualdev.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Weitere Infos: siehe http://www.gnupg.org

iD8DBQE6v2xaeyJldYarQ8ARAmubAJ466nGIGgOXFq3M6hRdsv5u2PHuOACfUbJg
fLJJdMc2/9tiYQztif9KDas=
=Es8x
-----END PGP SIGNATURE-----

Peter van der Linden

unread,
Mar 26, 2001, 6:50:49 PM3/26/01
to
>Does anyone know how to open the CD-ROM tray using Java? Is it possible to do
>so, or must some sort of C code be used?

There is no Java API to eject the CD tray. There is no C API to do that
either, come to think of it.

As you suggest, you will need to call an ioctl in the device driver using JNI.
Or, if your OS has a "cdeject" command, you could call that instead. That
is the approach I would use.

--
The Java FAQ is at
http://www.afu.com

Might be worth bookmarking it, or looking thru it for other info.

0 new messages