0

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?

yglodt
  • 13,807
  • 14
  • 91
  • 127
Wouter Pol
  • 1,031
  • 1
  • 8
  • 16

1 Answers1

1

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
Wouter Pol
  • 1,031
  • 1
  • 8
  • 16