issuing hard drive commands with java

醉酒当歌 提交于 2019-12-31 04:06:11

问题


Does anyone know of a way to issue commands to a hard drive within Java? Does Java even support this kind of hardware interaction?

For example, if I have a SCSI hard drive that I would like to inquiry, is there a pre-existing Java method to do this, or would I have to write my own?

http://en.wikipedia.org/wiki/SCSI has some general information on SCSI commands in case you aren't familiar.


回答1:


Java doesn't support talking directly to hardware like that. However, you can use JNI to call a C/C++ function from Java that can.




回答2:


Three words "JNI or JNA". I strongly recommend taking a look at the latter to see if it suits your situation, instead of just opting for JNI.




回答3:


No, since Java runs in a "virtual" machine rather than a real one. But it could be used as a bridge as dj mentioned earlier using JNI.

According to Wikipedia JNI can also call assembly directly. JNI could be used to call complete programs written in C or C++




回答4:


you need to write the HDD interface code in C/C++ and then call that from Java using JNI



来源:https://stackoverflow.com/questions/390463/issuing-hard-drive-commands-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!