I'm building a spring based javafx application which is aimed to run both on Linux and Windows machines.
I've encountered an error, and couldn't find a satisfying solution to the problem.
While trying to run the command sudo java -jar MS.jar
, I'm getting InvocationTargetException
:
Caused by: java.lang.UnsupportedOperationException: Unable to open DISPLAY
Of course, while executing java -jar MS.jar
alone, everything works great.
BTW, Running echo $DISPLAY
in terminal results with ":0"
The software is a javafx UI software, which needs sudo privileges for kernel tasks.
Machine details:
OS: OpenSuse 42.1
JAVA version: "1.8.0_152"
How can I resolve this issue?
Thanks!
Have you tried any of gtksudo/gtksu/kdesu
commands instead of sudo?
If your app is a UI app that should do the trick.
For more info see : https://linux.die.net/man/1/kdesu , http://www.linfo.org/kdesu.html