JRE acts differently on Ubuntu 10.04
I've created a Java application and converted it into JAR format to redistribute.
It works fine on Windows 7, Windows XP, SunOS and Mac OS X 10.5 ... but whenever I try to run it on Ubuntu 10.04 I run into a few problems:
When running the application it will randomly quit without warning and without any error messages. This does not happen on any other OS.
I'm using setVisible() to hide some buttons attached to a toolbar in my text editor. In Ubuntu, when a button is hidden using setVisible(false) the space on the toolbar is left blank - whilst in other OS'es the remaining buttons flow sideways to fill the gap.
For the second one, I've tried manually using validate() after setting buttons as not visible, but that doesn't seem to have any effect. It was working without validate() on the other OS'es anyway.
Can anyone tell me more or forward me to some more information about these Ubuntu-specific issues? Preferably I'd like a workaround that I can use to ensure that the program works the same on every OS.
Searching on Google for terms such as "ubuntu java setVisible(true) bug" doesn't give me many relevant results. I've only found one other forum post and that was in relation to a JFrame not acting properly when setVisible(true) was used on it - and the problem was never resolved by the original poster.
Edit: If you require code I can give it to you. But as the program works fine on all but one operating system, I haven't posted it.
leiger
Junior Poster in Training
91 posts since Jun 2010
Reputation Points: 33
Solved Threads: 6
To rephrase my question:
Is there another way to achieve the same effect as setVisible(true) for JButtons on a toolbar, that works on Ubuntu?
leiger
Junior Poster in Training
91 posts since Jun 2010
Reputation Points: 33
Solved Threads: 6
Have you tried this on some other *nix distribution like Fedora, Gentoo etc? If they manifest the same problem, it can be confirmed that this isn't a Ubuntu specific problem and more so a problem with the Java implementation for *nix. If the same issue doesn't show up, then you are better off asking the same question in Ubuntu official forums since this might be something "Ubuntu specific".
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Unfortunately I don't have access to any other Linux distro to test it.
I should probably write up a short test program, so that someone else on here can test it if they're running Fedora etc...
leiger
Junior Poster in Training
91 posts since Jun 2010
Reputation Points: 33
Solved Threads: 6
You should better check what installation of Java you using because Ubuntu 10.04 doesn't come with Sun Java and this has to be add it manually.
Simple check
java -version
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
You should better check what installation of Java you using because Ubuntu 10.04 doesn't come with Sun Java and this has to be add it manually.
Simple check
java -version
Would have replied earlier but was using Windows 7 at the time.
Here's the output from my Ubuntu installation:
~$ java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK Server VM (build 14.0-b16, mixed mode)
On Windows 7 I'm using 1.6.0_20 so although Ubuntu isn't using the latest version it's only 1-2 minor releases behind.
I'll see if there's an updated version of the OpenJDK available.
leiger
Junior Poster in Training
91 posts since Jun 2010
Reputation Points: 33
Solved Threads: 6
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
Thanks peter_budo for that link - am reading it now.
---
Hm it dows act strange. I done a quick basic test. When the setVisible(false) is executed it dissapears and the second button (that exec the function) comes in first's button place.
Could you please clarify what you mean by this?
You have two buttons:
[ A ] [ B ]
If you set A to be setVisible(false) ... does B move into A's place (like it does for me on Windows XP and Windows 7), or does B stay where it is and there's a gap where A used to be (what happens to be on Ubuntu) ?
Edit: And I'm using a JToolBar object, with buttons added to that. Not sure if that's significant (only just thought to mention it now). When you answer, could you also let me know if you're using a JToolBar, or a JPanel / JFrame / etc. ?
- leiger
leiger
Junior Poster in Training
91 posts since Jun 2010
Reputation Points: 33
Solved Threads: 6
So B moves to take the place of A, then moves back out when A re-materialises. I'm assuming that's what is meant to happen.
Doesn't work for me on Ubuntu 10.04, but it does work for you on 9.10 - I doubt that small difference would change anything? So it must be the JDK. I'll try installing the Sun JDK first and if that doesn't work, will re-install the OpenJDK.
Will post here with my results (I'm travelling and it'll be a few days before I am back home to try this).
leiger
Junior Poster in Training
91 posts since Jun 2010
Reputation Points: 33
Solved Threads: 6
Okay, I finally had a chance to install the SunJDK a couple of days ago, and once I told Ubuntu to use that one instead of the OpenJDK as it was doing by default, everything started working as expected.
I've since found out that the OpenJDK has a number of other bugs as well...
Thanks a lot for your help - I'm marking this thread as solved :)
leiger
Junior Poster in Training
91 posts since Jun 2010
Reputation Points: 33
Solved Threads: 6