I have a computer lab which is set up with piserver and 3B+ raspberry pis. I want my students to be able to write java code that will use the GPIO pins, so they will need to sudo java their programs. Unfortunately, sudo java any file is giving me a class not found exception. (it is a java course, we are going to be using pi4j and wiringpi, if only I can get even a simple program to run)
While troubleshooting the problem, I have simplified my program to a HelloWorld program and am trying to execute it using sudo.
I can run it with java HelloWorld without a problem.
When I try sudo java HelloWorld I get the class not found error.
When researching this I found that the user.home directory is set to /root ... and that it will need to be overridden (https://askubuntu.com/questions/659785/why-does-sudo-java-change-the-user-home-directory-to-root), so I tried this
java -Duser.home=$HOME HelloWorld
but, this does not fix the problem ... it still cannot find it (class not found error)
$HOME for me is /home/student
I have tried java -Duser.home=/home/student HelloWorld to no avail.
I am stuck. I have not been able to find anything else that addresses this issue.
root
when you add the user to the groupgpio
.java course
... using the termjava class
causes confusion