Thanks for the response Mark. I've done as you've suggested and moved the env vars to setenv.sh and explicitly set JAVA_HOME. Setting JAVA_HOME means I no longer need to change the -Djava.library.path but I still get the same error (X11 not found).
I definitely have an X11 server running on the server (which is really my laptop; I'm running all of this locally on my laptop--no remoting). Is it possible that the problem occurs because I am running Tomcat as a daemon? The command I use to start Tomcat is: sudo service tomcat6 start I've tried running startup.sh directly from the console but it doesn't work. It looks like /etc/init.d/tomcat6 sets up some env vars before starting Tomcat. I can try updating my environment so I can run startup.sh if you think it worth attempting. Thanks, DG ----- Original Message ----- From: "Mark Eggers" <its_toas...@yahoo.com> To: "Tomcat Users List" <users@tomcat.apache.org> Sent: Saturday, April 28, 2012 6:50:07 PM Subject: Re: Running Swing app under Tomcat 6 on Linux Comments and questions are in line. Please note I run Fedora / CentOS / Redhat and I'm not so familiar with Ubuntu. ----- Original Message ----- > From: "dgchristen...@comcast.net" <dgchristen...@comcast.net> > To: users@tomcat.apache.org > Cc: > Sent: Saturday, April 28, 2012 1:11 PM > Subject: Running Swing app under Tomcat 6 on Linux > > My version info: > > • Tomcat 6.0.28 > • Java 1.6 > • Ubuntu 10.4 > > > I have a small debugging/monitoring app written in Java/Swing that I'd like > to run inside Tomcat to help with debugging. The app is started by > dynamically loading the monitoring class from a webservice running under > Tomcat. The works in Windows (multiple flavors) but I'm having problems > getting this running on Ubuntu. What I've tried so far: What does this give you that monitoring the application via JMX (see VisualVM, jconsole), and debugging with your favorite IDE (NetBeans, Eclipse, IntelliJ) doesn't give you? You can actually do both locally as well as remotely (with a little bit of setup). > > 1) First error I got was an Headless exception. Since the app is a GUI app I > can't run in headless mode. After searching around I changed Tomcat's > library path (via -Djava.library.path in catalina.sh) to point to the > client lib (ie. .../java-6-sun-1.6.0.26/jre/lib/i386/client) instead of the > server lib. Try setting JRE_HOME in the environment to point to a JRE installation instead. Or use JAVA_HOME and point to the JDK. Tomcat will figure things out. If your environment is not set up by default to do that (mine is with custom.sh in /etc/profiles.d), create and use a setenv.sh script in CATALINA_HOME. In this set any CATALINA_OPTS, JAVA_OPTS, and other environment variables you need to. > > 2) After changing the libs the next error was that DISPLAY wasn't set. After > setting DISPLAY=0.0 in catalina.sh I get "Can't connect to X11 with > DISPLAY=0.0" error. I've tried different values for DISPLAY (e.g. > localhost:0.0) and nothing makes a difference. I've also tried fiddling > around with the policies in case there's a permissions error. See below for > the call stack. Are you running an X server? By that, are I mean is Ubuntu showing up in whatever GUI you've chosen (I guess Gnome 2 is that version's default)? If you only have a command line interface, then there's no place to create the screen. You can play games with a virtual frame buffer, but that will just allow your program to run, but without any screen output (obviously). Again, don't set the DISPLAY environment variable in catalina.sh. Set this in setenv.sh in the bin directory of CATALINA_HOME. There are lots of scenarios here. Three common ones come to mind. 1. Local X server You're at the console and running in a GUI environment. The display environment variable should already be set (typically :0.0). If you start Tomcat with your application in this environment, the GUI interface should just appear. 2. Remote client, accessing the GUI via a VNC server (such as TightVNC) Your display environment should already be set. For example, I'm currently on a remote CentOS 5.8 system via VNC. My DISPLAY environment variable is set to :0.2. If you start Tomcat with your application in this environment, the GUI interface should just appear in the VNC viewer (for example TightVNC). 3. Remote client, X server Note that an X server means your PC is serving the screen, keyboard, and mouse to a remote client (your application). To accomplish this you'll have to have an X server running (if you're on Windows, try XMing), and you'll have to set the DISPLAY variable appropriately. Running Java swing applications in this fashion is not very pleasant especially if your program is graphics-intensive. > The webservice app is a simple RESTEasy implementation. Since this works in > Windows I'm assuming (perhaps erroneously) that this can work in Linux. Any > help would be appreciated. > > Thanks, > DG > > java . lang . InternalError : Can 't connect to X11 window server using > ' : 0 . 0 ' as the value of the DISPLAY variable. > sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) > sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52) > sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155) > java.security.AccessController.doPrivileged(Native Method) > sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131) > java.lang.Class.forName0(Native Method) > java.lang.Class.forName(Class.java:169) > java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68) > > > java.awt.Window.init(Window.java:380) > java.awt.Window.<init>(Window.java:433) > java.awt.Frame.<init>(Frame.java:403) > java.awt.Frame.<init>(Frame.java:368) > javax.swing.JFrame.<init>(JFrame.java:158) > com.quinsoft.zeidon.objectbrowser.ObjectBrowser.startup(ObjectBrowser.java:60) > > This should work just fine if you're running an X server on your Ubuntu system. The DISPLAY environment variable should be :0.0 (no spaces) for a local machine. . . . . just my two cents. /mde/ --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org