简体   繁体   中英

Compilation using Pi4j

I run into the following problem: Upon running of the GPIO-example for my device built-in in Pi4J, I get an JNI error, followed by a NoClassDefFoundError for the com/pi4j/io/gpio/GpioProvider. After some searching (both here and other websites) I came to the conclusion that I was missing the pi4j-gpio-extension.jar. Turns out I have to include these specifically while compiling. I was using:

pi4j --compile Gpioblabla.java

which is a macro/shorthand/dont know for

+ javac -classpath '.:classes:*classes:/opt/pi4j/lib/*' -d . Gpioblabla.java

This successfully compiles. After running the program I get the NoClassDefError. So the question is, how to explicitly include certain .jar files in pi4j/javac compilation?

Found the error. You need to run it with the classpath as well. So run it like:

java -classpath '.:classes:*classes:/opt/pi4j/lib/*' Gpioblabla

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM