Without the library, you can get this error:
Could not locate the Phidget C library (libphidget22java.so). Make sure it is installed, and add it' s path to LD_LIBRARY_PATH. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1320) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE] at com.lupsha.phidgets.phidgetioserver.App.main(App.java:13) [classes!/:0.0.1-SNAPSHOT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [phidgetioserver-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [phidgetioserver-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [phidgetioserver-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [phidgetioserver-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.lupsha.phidgets.phidgetioserver.config.IOCardDetector]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError: no phidget22java in java.library.path Could not locate the Phidget C library (libphidget22java.so). Make sure it is installed, and add it' s path to LD_LIBRARY_PATH. at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:213) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1312) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] ... 25 common frames omitted Caused by: java.lang.ExceptionInInitializerError: no phidget22java in java.library.path Could not locate the Phidget C library (libphidget22java.so). Make sure it is installed, and add it' s path to LD_LIBRARY_PATH. at com.phidget22.PhidgetBase.<clinit>(PhidgetBase.java:33) ~[phidget22-1.5.20191018.jar!/:na] at com.lupsha.phidgets.phidgetioserver.config.IOCardDetector.<init>(IOCardDetector.java:36) ~[classes!/:0.0.1-SNAPSHOT] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_212] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_212] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_212] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_212] at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:200) ~[spring-beans-5.2.0.RELEASE.jar!/:5.2.0.RELEASE] ... 27 common frames omitted
The library install:
# be root sudo su cd # get dev stuff apt-get install libusb-dev # get the lib for java, (2019), see https://www.phidgets.com/downloads/phidget22/libraries/linux/libphidget22java/ for updates, etc. wget https://www.phidgets.com/downloads/phidget22/libraries/linux/libphidget22java/libphidget22java-1.5.20191101.tar.gz # unpackage tar xzvf libphidget22java-1.5.20191101.tar.gz # enter the directory, the version will be whatever the latest is ls cd libphidget22java-1.5.20191101 # start the configure process ./configure # compile it. Go do something, this will take forever. (22 minutes on a Pi3 in 2019 for the java library, 44 minutes for the linux library) make # make an install of it sudo make install
Add the library path:
# type it in and export it, or add it to your .bashrc file LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH # run your program, and you have to run it as ROOT to detect the Phidgets board sudo java -jar phidgetioserver-0.0.1-SNAPSHOT.jar
Or in a bash file: nano /home/pi/iocardserver/run.sh
#!/bin/bash cd /home/pi/iocardserver nohup sudo java -jar phidgetioserver-0.0.1-SNAPSHOT.jar &
and tail -F nohup.out