Sorry to post it in the Java ME community. It is really an SE question with the jdk.dio libraries from ME.
After my unresolved problems with opening /dev/servoblaster pipe from Java ME (see my other post), I switched to Java SE and added the jdk.dio libraries, both in netbeans and on the raspberry Pi.
Opening servoblaster works fine but now a new problem:
I am trying the same code that worked perfectly in Java ME to open a GPIO Pin for input, as show below. Doing this in Java SE with jdk.dio results in a nullpointerexception on the last statement when I try to check whether the Pin is opened. I get the same error when I try to set a value of the Pin. No error message on de DeviceManager.open statement.
Since this works without problems in the Java ME environment I suspect is has something to do with the setup of the remote device and related permissions.
I SE the setup of the remote device is different and as far as I can see I can't see the permission in the same way as for a Java ME embeddeddevice. In netbeans I defined the Pi as a remote runtime platform and during the build it connects and compiles without problems.
The permissions I have set on the Pi. Since I found the security instructions rather unclear I have added the GPIOPin GPIOPort and DeviceMgmt permissions to several files (better safe than sorry :-) )
/dev/test/java.policy
/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/lib/security/java.policy
/homr/pi/NetBeansProjects/MyProjectName/dist/gpio.policy
but this does not make a difference.
I also defined the additional B+ GPIO pins in /dev/config/dio.properties-raspberrypi
Any idea why this does not work? Any advice appreciated.
regards,
Willem
code used:
GPIOPinConfig config2 = new GPIOPinConfig(portID, 12, GPIOPinConfig.DIR_INPUT_ONLY, DeviceConfig.DEFAULT, GPIOPinConfig.TRIGGER_BOTH_EDGES, false);
try {
HCSR04Receive = DeviceManager.open(config2);
} catch (IOException ex) {
Logger.getLogger(hcsr04me.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(HCSR04Receive.isOpen());