Problems with Java

The X Window System integration in most modern implementations of the Java virtual machine (JVM) displays only empty, gray windows when used with many non-re-parenting window managers, such as Awesome. This is almost certainly a violation of ICCCM and has been reported to Sun Microsystems a number of times.

Version 1.8
If you can't seem switch to a Java window using your keyboard, add the following to your rc.lua:

function delay_raise -- 5 ms ages in computer time, but I won't notice it. local raise_timer = timer { timeout = 0.005 } raise_timer:add_signal("timeout",			 function			   if client.focus then			       client.focus:raise			    end			    raise_timer:stop   end) raise_timer:start end

Then, replace all instances of if client.focus then client.focus:raise end with delay_raise. Note that Mod4-Tab has it formatted slightly differently.

Sun JVM
Although lots of java applications seem to work fine, at least the intellij and netbeans versions as of 2011-11-21 don't seem to work.

OpenJDK
Intellij and netbeans work with the fix described below. Most other java apps seem to work fine even without the fix.

Recent Changes
As of Java 1.7 and Awesome 3.5 the fixes described below may actually cause undesirable behaviour related to menus. Awesome is now, apparently, a reparenting window manager as of this commit. If you are experiencing problems having applied the 'wmname' and '_JAVA_AWT_WM_NONREPARENTING' fixes against a recent Java and Awesome try removing both fixes.

This behaviour was observed with the awesome-git package in Arch Linux as of 2013-07-14.

As of 2014-01-24 there are still ongoing problems with some Java Swing applications, in particular with respect to multiple monitors and the rendering of drop-down menus. The best current workaround at present seems to be to make these windows floating. A bug report has been filed and is tentatively projected to be fixed in release 3.5.3.

Multi-screen setup
It might work if you launch your java application with '_JAVA_AWT_WM_NONREPARENTING' environment variable set on the first (as defined in your X11/Xorg configuration file) screen.

JetBrains IDEs
If you're experiencing any menu-related issues in JetBrain's IDEs, you can try disabling all other fixes and use this script with "Sawfish" instead of "LG3D" for IRONIC_WM_NAME. It may also help with other java issues, but i can't confirm it.

As of PhpStorm, it was fixed in EAP build 138.826.

Visual Paradigm
Setting the wmname to LG3D doesn't work with Visual Paradigm. However, it works with Sawfish:

wmname Sawfish

Use OpenJDK With Vendor Fix
The versions of OpenJDK that ship with some operating system distributions&mdash;at least Debian (and Ubuntu) and Arch Linux in March and August of 2009, respectively&mdash;have had this problem fixed by the vendors. Just set the environment variable  to any value to inform the JVM that your window manager does not re-parent.

$ _JAVA_AWT_WM_NONREPARENTING=1; export _JAVA_AWT_WM_NONREPARENTING

As of 17 September 2009, this patch has not been applied upstream by Sun Microsystems.

Impersonate Another Window Manager
You may use the utility to make the JVM believe you are running a different window manager. This utility is available in the  package in Debian (and Ubuntu); this Portage tree provides   for Funtoo (and Gentoo).

$ wmname LG3D

(You must restart the application in question after issuing the wmname command.)

This works because the JVM contains a hard-coded list of known non-re-parenting window managers. For maximum irony, many users prefer to impersonate &ldquo; ,&rdquo; the non-re-parenting window manager written by Sun, in Java.

Use Legacy, Motif-based Integration
The Motif-based X integration used in older versions of the JVM does not have the particular problem of empty, gray windows, though it may have other bugs and is no longer actively developed. To use the Motif-based X integration, set the environment variable  to the value. This is the solution described in Awesome&rsquo;s manual page.

$ AWT_TOOLKIT=MToolkit; export AWT_TOOLKIT

Be warned that the Motif X integration is absent from free software JVMs such as OpenJDK and IcedTea, and it has at least one known crashing bug on AMD64.

Version 1.4
Versions 1.4 and earlier of the JVM&rsquo;s X integration are based on Motif and are not known to have the problem described here. Of course, this version of the JVM has not been supported by any major vendor for some time, so using it likely comes with other hazards.