1

I installed openJDK8 on a Raspberry Pi 0H with RaspiOS Lite (BUSTER). I also installed wiringpi and pi4j libraries. I added the directories to CLASSPATH in the /etc/environment file and even tried to export it, but java & javac seem to ignore the variable. I have to specify the classpath every time I compile or run my code. GOOGLE does not show any info on it, every mention I found was to use -cp.

Is there no way to specify a CLASSPATH variable for openJDK8?

2
  • Why not export it from /home/pi/.bashrc? – Dougie Jul 7 '20 at 7:53
  • Two things; add the contents of /etc/environment to your post, and double check the value is what you think it is by including the output of echo $CLASSPATH – Nick Jul 7 '20 at 16:48
0

As a general rule it's a bad idea to set the classpath at the user or OS level.

You better set it up during build using Ant, Maven, or Gradle. At runtime you can set it on the startup BASH/SH script.

Why? Because different applications may want to use different libraries. Maybe even different versions of the same library. If you set it at the user level, then one app may end up running the correct version of the library, but another will run (and inexplicable crash) since it's running the wrong one for itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.