Is it possible to code a device driver in Java?

后端 未结 13 1265
猫巷女王i
猫巷女王i 2020-12-04 20:04

Introduction

I heard something about writing device drivers in Java (heard as in \"with my ears\", not from the internet) and was wondering... I always thought dev

13条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 20:45

    First of all, note that I'm not an expert on device drivers (though I wrote a few myself back in the day), much less an expert on Java.

    Let's leave the fact that writing device drivers in a high-level language is not a good idea (for performance and possibly many other reasons) aside for a moment, and answer your question.

    You can write device drivers in almost any language, at least in theory.

    However, most device drivers need to do plenty of low-level stuff like handling interrupts and communicating with the OS using the OS APIs and system calls, which I believe you can't do in Java.

    But, if your device communicates using, say, a serial port or USB, and if the OS doesn't necessarily need to be aware of the device (only your application will access the device*), then you can write the driver in any language that provides the necessary means to access the device.

    So for example you probably can't write a SCSI card driver in Java, but you can write a driver for a proprietary control device, USB lava lamp, license dongle, etc.

    * The obvious question here is, of course, does that count as a driver?

提交回复
热议问题