title: Run javafx jar as sudo: Unable to open DISPLAY
body: <p>I'm building a spring based javafx application which is aimed to run both on Linux and Windows machines.  </p>
  
  <p>I've encountered an error, and couldn't find a satisfying solution to the problem.<br>
  While trying to run the command <code>sudo java -jar MS.jar</code>, I'm getting <code>InvocationTargetException</code>:<br>
  <code>Caused by: java.lang.UnsupportedOperationException: Unable to open DISPLAY</code></p>
  
  <p>Of course, while executing <code>java -jar MS.jar</code> alone, everything works great.  </p>
  
  <p>BTW, Running <code>echo $DISPLAY</code> in terminal results with ":0"</p>
  
  <p>The software is a javafx UI software, which needs sudo privileges for kernel tasks.</p>
  
  <p><strong>Machine details:</strong><br>
  <strong>OS</strong>: OpenSuse 42.1<br>
  <strong>JAVA version</strong>: "1.8.0_152"</p>
  
  <p>How can I resolve this issue?</p>
  
  <p>Thanks!</p>