X11 Display variable and crontab problem
Hi all, I have a Java application that can be run either via a GUI or solely via the command line. The JVM will unfortunately import X11 related packages/libraries regardless if the GUI is used or not. I log in to the remote server using cygwin and ssh. *The application runs fine as a non-root user. *The application however throws the following X11 exception if run as root through "su -". [java] Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. [java] at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) [java] at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:125) [java] at java.lang.Class.forName0(Native Method) [java] at java.lang.Class.forName(Class.java:140) [java] at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnviron ment.java:62) [java] at java.awt.Window.init(Window.java:224) [java] at java.awt.Window.<init>(Window.java:268) [java] at java.awt.Frame.<init>(Frame.java:398) [java] at java.awt.Frame.<init>(Frame.java:363) [java] at javax.swing.JFrame.<init>(JFrame.java:154) [java] at org.hlsi.imscpLoad.LoadIMSContentPackaging.<init>(LoadIMSContentPackagin g.java:122) [java] at org.hlsi.imscpLoad.MainApp.go(MainApp.java:122) [java] at org.hlsi.imscpLoad.MainApp.main(MainApp.java:183) *I got around this problem by using "sux -" rather than "su -", no exceptions are thrown. So far so good... My real concern is how to invoke this application through crontab. I am not sure how to diagnose the problem. Surprisingly, for me at least, setting up a NON-ROOT user crontab and running it throws the same exception as above. What environment does a non-root user pick up? [Also, to my surprise, a file that is created by the non-root cron script is owned by root, and not the non-root user.] Of course, setting up a root cronscript gives the same exception. So my question is: apart from refactoring the Java code, what options do I have to run the Java application on a regular basis. *is there a quick fix? *would I have to try to set up the X11 environment in the cronscript? *is refactoring the code the only option? Any help would be much appreciated since it has been bugging me for a while. Regards Jon Loken My environment: SUSE Enterprise Server - version 9 Connection to remote server is through cygwin and ssh.
On Fri, 2005-11-11 at 13:34 +0000, Jon Loken wrote:
Hi all, I have a Java application that can be run either via a GUI or solely via the command line. The JVM will unfortunately import X11 related packages/libraries regardless if the GUI is used or not. I log in to the remote server using cygwin and ssh.
*The application runs fine as a non-root user. *The application however throws the following X11 exception if run as root through "su -". [java] Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. [java] at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) [java] at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:125) [java] at java.lang.Class.forName0(Native Method) [java] at java.lang.Class.forName(Class.java:140) [java] at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnviron ment.java:62) [java] at java.awt.Window.init(Window.java:224) [java] at java.awt.Window.<init>(Window.java:268) [java] at java.awt.Frame.<init>(Frame.java:398) [java] at java.awt.Frame.<init>(Frame.java:363) [java] at javax.swing.JFrame.<init>(JFrame.java:154) [java] at org.hlsi.imscpLoad.LoadIMSContentPackaging.<init>(LoadIMSContentPackagin g.java:122) [java] at org.hlsi.imscpLoad.MainApp.go(MainApp.java:122) [java] at org.hlsi.imscpLoad.MainApp.main(MainApp.java:183)
*I got around this problem by using "sux -" rather than "su -", no exceptions are thrown.
So far so good... My real concern is how to invoke this application through crontab. I am
hi, try adding -Djava.awt.headless=true to your launcher/application good luck...
participants (2)
-
Gustavo Dutra
-
Jon Loken