Does anyone know of a way to issue commands to a hard drive within Java? Does Java even support this kind of hardware interaction?
有谁知道在Java中向硬盘驱动器发出命令的方法? Java甚至支持这种硬件交互吗?
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?
例如,如果我有一个我想查询的SCSI硬盘驱动器,是否有预先存在的Java方法来执行此操作,或者我是否必须自己编写?
http://en.wikipedia.org/wiki/SCSI has some general information on SCSI commands in case you aren't familiar.
http://en.wikipedia.org/wiki/SCSI有一些关于SCSI命令的一般信息,以防您不熟悉。
4 个解决方案
#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.
Java不支持直接与这样的硬件对话。但是,您可以使用JNI从Java调用C / C ++函数。
#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.
三个字“JNI或JNA”。我强烈建议看一下后者,看它是否适合你的情况,而不是只选择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.
不,因为Java在“虚拟”机器而不是真实机器中运行。但它可以用作前面提到的使用JNI的dj的桥梁。
According to Wikipedia JNI can also call assembly directly. JNI could be used to call complete programs written in C or C++
根据*,JNI也可以直接调用汇编。 JNI可用于调用用C或C ++编写的完整程序
#4
you need to write the HDD interface code in C/C++ and then call that from Java using JNI
你需要用C / C ++编写硬盘接口代码,然后用JNI从Java调用它
#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.
Java不支持直接与这样的硬件对话。但是,您可以使用JNI从Java调用C / C ++函数。
#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.
三个字“JNI或JNA”。我强烈建议看一下后者,看它是否适合你的情况,而不是只选择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.
不,因为Java在“虚拟”机器而不是真实机器中运行。但它可以用作前面提到的使用JNI的dj的桥梁。
According to Wikipedia JNI can also call assembly directly. JNI could be used to call complete programs written in C or C++
根据*,JNI也可以直接调用汇编。 JNI可用于调用用C或C ++编写的完整程序
#4
you need to write the HDD interface code in C/C++ and then call that from Java using JNI
你需要用C / C ++编写硬盘接口代码,然后用JNI从Java调用它