Can Java control hardware devices on PC?

2.3k Views Asked by At

I have searched and have no answer about Java support control hardware on PC as c/c++. I wondered Java can control devices such as CD-ROM, speaker, especially Bluetooth?. Thank you so much!

2

There are 2 best solutions below

0
On

Since Java requires your system to have JVM installed along with the JDK/JRE environment; it does not run directly with the system. Therefore, no it cannot directly control your system besides memory usage.

Yet like the comment also reinforces you can use Jni calls to work with system hardware but it won't actually allow you to work "directly with the hardware".

You can easily search for Jni on google to find resource.

0
On

Java can access hardware devices like keyboard, mouse, hard drive, network card and the like because it can call the C code through Java Native Interface (JNI). Without this, Java would we a useless "thing in itself". If you look into sources of the Java system library, you will see many native method calls.

JNI can also be used from the user Java code, so Java is capable of controllingmost (if not all) hardware devices that C code could.