I have a very weird problem with a Java GUI that I've built at work. It is so weird I don't even know where to start to look for help!!

We have a standalone system at an offsite location consisting of a Windows PC, running XP, and a SuSE Linux machine. I built a Java GUI that runs some bash scripts on the Linux machine. The GUI is started from the Windows machine because the user is not a Linux person. The GUI was built to replace scripts that presented the user with command line prompts for providing inputs to the main processing scripts.

The user clicks an icon on the windows desktop which runs a DOS batch (*.bat) file. The batch file uses plink, with a stored PuTTY session, to connect to the Linux machine and to execute a "java -jar XXX.jar" command to start the GUI. The GUI displays on the Windows PC due to Cygwin/X X Server running on the windows PC.

Okay. Now for the weirdness. If I leave the GUI in the location where it initially pops up, everything is fine. If I move the GUI, then the pulldown menus (dropdown combo boxes and menubar pulldowns) no longer work properly. And ONLY the pulldown menus. Everything else works fine (pushbuttons, text fields, ...). If I move the GUI back to its original location, everything works fine. If I click, hold and drag the mouse cursor over to where the GUI initially popped up (leaving the GUI where I moved it) the pulldown menus work properly.

At first I thought I had a problem with the way I initialized the pull down menus but I'm not so sure anymore. I'm wondering if there is something weird going on with the windows <-> putty <-> linux or the Xwin setups.

Contributing to not being able to solve this is that I cannot replicate this behavior at work. Unfortunately we don't have an exact replica of the offsite system; I'm testing/building this GUI on a XP to Debian Linux machine.

As anybody seen anything like this? Any suggestion as to what might be going on here?

Thanks times a billion



I don't think running Java through X redirection is a good idea.

Why don't you put the Java program on the Windows PC and use it to launch plink and run the command? If you have the source code of the Java program, it should be trivial to add a class that wraps and replaces Runtime.getRuntime().exec() and put plink in front of the command line. Then maybe you can work on the class a bit for it to use one plink session for everything. Then you can also make another class with the same interface but does not add the plink so your Java program can run on both Windows and Linux.

  • Thanks ... I didn't think of that-using plink to run the scripts instead of the GUI :) Just curious, why is running Java through X redirection a bad idea? – Bill Doss Jan 27 '12 at 14:54
  • I reworked my source code to run on windows and use plink to execute the commands on the linux machine. Because this works, I will consider this question "solved". Thanks!!!!!!!! – Bill Doss Feb 8 '12 at 0:36
  • (Sorry, somehow the notification for your first comment is ignored.) It's not a good idea because it's unnecessary overhead and is really slow and unstable. – billc.cn Feb 8 '12 at 10:33

With Java 1.7 you can use -Dsun.java2d.xrender=true when using a remote X Display. It makes java aware that is running in X. See http://docs.oracle.com/javase/7/docs/technotes/guides/2d/flags.html


It might have something to do with hardware acceleration of Java 2D, Java's graphics system.

Try turning off any hardware acceleration by adding the following command line option of the Java process:


There is also a full reference to Java 2D settings here. Turning Direct 3D off will make the UI slower, but for simple UIs with just menus and no animations it shouldn't matter.

  • Thanks. I will try that next when we go back to the offsite location. – Bill Doss Jan 27 '12 at 14:52

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.