Monday, 29 May 2017

Java on Pi: adding JAR library

Note that colons, not semicolons, separate the classpath parameters when compiling a Java program. You may also need to run as sudo if you are accessing any protected folders.

javac -cp ".:/opt/pi4j/lib/pi4j-core.jar"


javac -classpath '.:classes:*:classes:/opt/pi4j/lib/*' -d . /home/pi/Java_Weather/

Note that you still need the classpath when running the code:

java -cp ".:/opt/pi4j/lib/*:" BME280

or explicitly defining the path:
java -cp ".:/opt/pi4j/lib/*:/home/pi/Java_Weather/:" BME280

No comments:

Post a Comment