Hey Every One,

Is there a package or written class to access hardwares like cd rom by using a java code.i had referred the java documentation but i didnt found.If any one know about this please send me a feed back. i referred some basic books also like( java in 21 days ).but i cant found it in books.Thanks.

Nuwan.

Dani AI

Generated

This thread is mixing two different problems. As asked, the right approach depends on the goal: reading files that happen to be on a CD, or performing drive-level operations (eject/lock/burn/read raw sectors). touched on the file side; below are practical, current options for the hardware/control side that go beyond simple file I/O.

For drive/control tasks the JDK does not provide a single cross-platform device API. Common approaches:

  • Call platform command-line tools from Java (quickest). Example utilities: eject on many Unix systems or macOS tools such as drutil. A minimal ProcessBuilder example:

    Process p = new ProcessBuilder("eject", "/dev/cdrom")
        .redirectErrorStream(true)
        .start();
    int exit = p.waitFor();
  • Use native APIs from Java by writing JNI code or using JNA to call OS libraries (Windows MCI or DeviceIoControl, Linux ioctl). JNA avoids writing C glue code and is faster to prototype; JNI gives full control for production.

Useful references:

Practical notes: device names, permissions and available commands differ by OS; many operations require elevated rights; burning or raw-sector access typically needs vendor tools or native libraries. For quick tasks, wrap proven command-line tools from Java. For robust cross-platform control, write a small native wrapper (via JNA or JNI) and invoke it from Java, testing per-OS.

Recommended Answers

All 2 Replies

What kind of information are you looking for in the CD Rom?

You use File and the various input streams, just like any other file you would access. The CD rom is just another drive, you know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.