07 February 2007

Java Programming & Beryl Problems

There is a bug in Sun Java's Swing. It doesn't like certain window managers. Something about reparenting and not reparenting or something like that. Whatever. The point is, when trying to run a program you wrote using Swing, all you get is a big white nothing. Nothing draws in the window. Ahhh! What's wrong?! Yeah, I had some trouble with my Java class because of that one. Well, unfortunately, my favourite WM, Beryl, is a problem child with this. However, there is an easy fix for it. Open your .bashrc (that in ~). If you don't know how, do this in the terminal:gksudu gedit ~/.bashrc Add this line to it:

export AWT_TOOLKIT=MToolkit

Now try to run your program again. Now everything works. Yay!


Anonymous said...

In Ubuntu Freist Frawn this tip does not work jdk 1.5.05

Mackenzie said...

Were you trying to run a Java-based app that's listed in your menu? If so, it won't work. You have to run the program from the terminal. I didn't test with Java 5 (1.5) though, so you could be right. It definitely works with Java 6.

apocalypseneon said...

It was that!!
Thx a lot.

apocalypseneon said...

I confirm, it works with java 1.5 too

apocalypseneon said...

There are some problems of rendering, anyway. Most of windows does not render correctly contents, I have to hand-modify dimensions to see them, probably because doing so a repaint is forced... It happens with all kinds of windows, not only java...

apocalypseneon said...

Restarting the system resolved the problem

Suds said...

Thanks for the tip. Was having a problem with squirrelsql and this solved it (even though I dont understand what is happening by setting this environment variable). Just what the doctor prescribed.

Graeme Lawton said...

Worked for me, however now Squirrel SQL loads, but I can't use my keyboard within it.

samantha said...

Doesn't work on the thinkorswim java desktop trading app on 64 bit feisty fawn and Java 1.6. Can't launch. Get

samantha@wallpapers$ export AWT_TOOLKIT=MToolkit
samantha@wallpapers$ cd ~/think2
samantha@think2$ ./thinkorswim
# An unexpected error has been detected by Java Runtime Environment:
# SIGSEGV (0xb) at pc=0x00002b37b6047385, pid=19929, tid=1089702208
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.6.0_02-b05 mixed mode)
# Problematic frame:
# C [libc.so.6+0x2f385] catgets+0x15
# An error report file with more information is saved as hs_err_pid19929.log
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
Aborted (core dumped)

Mackenzie said...

O_o Well, without the export bit, is the error still there? The export thing just makes it use a different widget library because the default one hates Beryl. The programs still run, you just don't see any of the buttons or anything--no errors.

Anonymous said...

seems to work for me. That's cool. It was really annoying as i use (write) a lot a java swing applications.