
As you can see, it works when running as non sudo. I however need to run it as sudo.
I have faced this error this comes when there is classpath issue. Set classpath from command prompt, do via terminal, like java -Djava.library.path=blahblahblah...
liked helping you.
Try either using sudo -E (which will pass your environment variables to the sudo environment), or pass the specific environment variables that you wish:
sudo LD_LIBRARY_PATH="$LD_LIBRARY_PATH" CLASSPATH="$CLASSPATH" java ...
(You may not need to pass the CLASSPATH, you can try with or without it).