How do you (or can you) write device drivers with Java?

Brian O'Byrne

It is not possible to write device drivers in pure Java. Device drivers typically require direct access to memory, IRQs, DMA channels or other machine resources, as well as connections to the operating system. Java simply does not have these resources available to it (and cannot have them while being platform-independent).

What you can do is define a Java API which is an abstraction of the devices, and implement this API on many systems using native calls. You would be writing the device driver in a language appropriate to the target machine, and then defining Java classes which call this native code in a well-defined way.

This is what Sun have done throughout the language, with the networking, filesystem, and other components which have a common interface but different implementation on different platforms.

For a nice isolated example of how it is done, have a look at the Comm API from Sun. The different platforms available support the same Java classes, but depend upon some native code delivered with these classes.
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact