0

Is there a way in java to get the input from say a proximity sensor which gives out analog/digital data and display it on the screen.

If it does take analog/dital inputs how does one sync a hardware device such as a proximity sensor and java.

Just researching at this this stage.

If there is a way for java to function with this off beat devices and use this kind of data in our applications.

gautam vegeta
  • 653
  • 6
  • 13
  • 28
  • 1
    Java can use anything which is available to the OS. If you have an OS driver which makes your device look like a file system or serial device, you can access it from Java. i.e. the real issue is between your device, your machine and your OS. .... Made this an answer ;) – Peter Lawrey Aug 04 '12 at 10:47
  • As @Peter already mentioned, it's all about the API and whether you can integrate it into the Java runtime (keep in mind that you can access native APIs via JNI, etc.). You have to assess each sensor regarding its integration capabilities. – home Aug 04 '12 at 10:52

2 Answers2

2

Java can use anything which is available to the OS. If you have an OS driver which makes your device look like a file system or serial device, you can access it from Java. i.e. the real issue is between your device, your machine and your OS.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

COM port reading example taken from: http://www.java-samples.com/showtutorial.php?tutorialid=11

import java.io.*;
import java.util.*;
import javax.comm.*;

....
....
...

SerialPort serialPort;
...
...
try {
        serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
    } catch (PortInUseException e) {System.out.println(e);}
huseyin tugrul buyukisik
  • 11,469
  • 4
  • 45
  • 97