Java swing components not displayed properly outside netbeans - java

I have developed a Java Swing application. When running the application in Netbeans IDE, everything works properly (see http://www.fkserv.ugent.be/vrg/tom_dierickx/Screenshot2.png for a screenshot).
After building the project to .jar and running it in command line, the application window appears but the components are not displayed properly (See http://www.fkserv.ugent.be/vrg/tom_dierickx/Screenshot1.png for a screenshot).
Does anyone have experienced this before and may have a solution to this problem?
As the thread points out, this seems to be a Ubuntu-related problem. I experienced no trouble when running the application on a windows system.
Some threads on the web contribute the defect to Compiz or Beryl. However, I never installed these graphic-tools. However, I ran a line of code I found on the net for uninstalling Compiz. It seemed that Compiz was installed by default. Unfortunately, the problem remains. Beryl doesn't seem to be installed.
The threads also note to add export AWT_TOOLKIT="MToolkit", but this doesn't seem to work either.
No runtime errors where generated on the command line.
Any suggestions?

After some testing, I came to following conclusions:
The application runs on Windows, but not on Ubuntu.
Some Swing applications run on Ubuntu, while others don't.
Hence it seems like the problem is due to one or a few Swing components which do not work in Ubuntu. I think it's best for now to avoid these components by testing what works and what does not.

Related

How I can find why Windows is blocking java.exe?

I encounter some very strange behavior and I don't know how to handle it.
I suspect that the behavior started to reproduce after last Windows upgrade. But I am not sure if it has anything related to it. (I discovered it when I tried to run maven, which uses java)
The behavior is the following: when run java (e.g. java.exe -version) from command line, it does nothing (like below). The process looks like it is hanged.
enter image description here
I did the following tests:
make a clone of java.exe (e.g. jv.exe) and run it. It works.enter image description here
rename another application to java.exe (e.g. processmonitor.exe to java.exe). When run application, it doesn't open.enter image description here
renamed java.exe to java.exe.bkp and make a link 'java.exe' to 'jv.exe' (which works), and the process is hanged.
make another link java1.exe to jv.exe and it works.enter image description here
did all the operations with&without network, and no difference (java.exe doesn't work, the others work)
restart windows in 'save mode' (+/- network) and java.exe works
I disabled the firewall from windows, and/or I added rules for java.exe. It doesn't work.
Initially I had many JVMs installed. I uninstalled all of them and installed only the one in images. All above tests are made after new installation.
Also, I observed that every time I run java.exe (but not when I run jv.exe or java1.exe) there is a new file java.exe.XXX.dat created in c:\Users\user.name\AppVerifierLogs.enter image description here Searching on google, it seems that is some kind of log file, which can be viewed with this application (https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/application-verifier) but I don't find the standalone application. Maybe it is already installed in the system, but I don't know where or how to enable it.
It seems that for some reason, the Windows is blocking all processes named 'java', no matter if it is actually the java program or any other application. But I'm out of ideas regarding what could be the cause, or how to continue to investigate.
If anyone can help me, I will be grateful to him.
Thank you.

Strategies for debugging a runtime Java crash that runs correctly in NetBeans

Sorry in advance. This is a really vague question because I have no idea whatsoever what is going on. I have a Java Swing GUI desktop app that I wrote in NetBeans. While inside of NetBeans, the app works fine and passes all of the tests that I have thrown at it. I've been developing this app over the past several months, deploying it at various phases of its development.
Yesterday, I finished adding and testing some new functionality. I built the application and put it on another computer. I then went to run the program (outside of NetBeans) straight from the jar file. While in the new areas (JDialog boxes), the program crashes. Since I am not in an IDE, I have no feedback to see what is wrong.
The only thing that I can think of (and this is lame) is that I added some switch statements that switch on strings, which I know to new to 1.7. I was previously developing in 1.6. Otherwise, I can think of no reason that the program should work flawlessly inside the IDE, but crash outside of it.
Can anyone offer any suggestions for how I should approach this? I'm at a complete loss.
Thanks very much.
The next debugging step for you is reducing the size of your program until it doesn't crash, then seeing what change you made worked. That should either make the answer obvious or give you a good question to post on SO.
Your idea that it might have to do with switch statements tells you to try:
removing them
removing and compiling on JDK 6 and see if it works
Those are reasonable ways to reduce your program size to see if you can make it run.
I would start from collecting a crash dump data.
If you run the UI on windows you could use DrWatson
If you run the UI in Linux , By default the heap dump is created in a file called java_pidpid.hprof in the working directory of the VM. unless you specify the path yourself by adding this -XX:HeapDumpPath= option to your UI java options.

Rogue instance of older version of my Java app running in background?

I'm new to Java (come from C++/.NET background) and am experiencing very strange error. I am developing w/ Eclipse IDE on Windows XP on my local desktop. It seems that for some reason, an older (and of course buggier) instance of my application stays running for some very odd reason which I cannot understand.
Even when I close eclipse, this old version of my application is running in the background. So unless I reboot, when I try to test new version of the code, this 'old, rogue instance' is fighting for the resources that are used (files on a share) with the newer (hopfully less buggy) version of the code.
Has anyone experienced this? Does the JVM cache old versions of your Java application for some reason? What am I missing here? When I reboot my machine, the instance finally dies...
I was ripping my hair out trying to figure out why the new version of my code still had the same old bug until I realized this was happening... shrug
Thanks for any help!
Do you by chance either run your program multiple times, or have forgotten to close one instance of it prior to re-running it from Eclipse?
One thing, that is not very obvious when using Eclipse, is that it allows to run any number of instances of Java programs simultaneously. When you have the Console view active, you have the option to terminate the latest launch.
To switch the console to a different launch (if there are multiple running) you can select from a list, by pressing the "Display Selected Console" icon, which is the monitor icon to the top-right in the Console view.
You can also remove any and all terminated launch console outputs from the Console view, by pressing "Remove All Terminated Launches", if every launch have been terminated it should now display "No consoles to display at this time", otherwise the next-newest running launch will be brought to the top.
If this isn't the problem, and indeed Eclipse have lost track of a launch (which is quite rare, but can happen - especially if you spawn sub processes yourself), you can safely terminate any run-amock java.exe process from the Task Manager, as Eclipse runs wrapped in a Windows executable on the Windows platform.
Java applications run under "java.exe", so you can look for that in the task list. Sadly, if several Java applications are running at the same time, it's hard to tell which is which.
I'm not terribly familiar with Eclipse, but it seems like Eclipse should tell your old version to terminate when you close Eclipse. The JVM doesn't cache past versions.
Hope this helps.
I had a problem like this as well. I would try to run the program after making changes, and it would run the older version of it, and still report errors and stop on lines that I had even commented out. I tried micdah's solution, but there were no java.exe processes in Task Manager. I solved the problem by killing the Eclipse process from the Task Manager, which closed the program without saving Eclipse Workspace settings. When I relaunched, everything I had saved in the .java files launched normally.
Could be a bug in Eclipse. Could be some code in your application that's spawning a new process. Impossible to tell from over here.
If you haven't already, check out the jps tool, which is included with the regular JDK. It might make it easier to diagnose the problem.

SWT Browser Problem on Vista

We're running Java Swing and are using an SWT bridge to get ahold of the SWT browser. Everything normally works just fine, but we have a problem on a Vista test machine. It worked fine until just a week ago or so. The call stack:
org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:3589)
at org.eclipse.swt.SWT.error(SWT.java:3481)
at org.eclipse.swt.SWT.error(SWT.java:3452)
at org.eclipse.swt.browser.IE.create(IE.java:184)
at org.eclipse.swt.browser.Browser.<init>(Browser.java:109)
...
I have tried IE7 and IE8 through the SWT browser, but none is working (XULRunner is not applicable on our application since we need two browser instances).
XP, Windows7 and Vista is working on other machines, and I can't exclude something being correpted on this specific machine. We got some Windows updates close to when this error started happening, they seem related. It is a our only Vista test machine with a virtual screen, has there been any Windows updates for IE relating to virtual screens that could cause this? To me it looks like a likely target for security holes, so maybe that could be it?
I know this is looking for a needle in a haystack, but has anybody seen anything similar lately?
Edit: looking at the source, I see that the IE.create method swallows an exception to throw this error - I'd step into the WebSite constructor to try and figure out what's happening.
My solution is not to embed the SWTBrowser into our Swing application at all. (I've always hated web tech on desktop apps anyway. :)

Why do my Swing application windows intermittently not close when the application exits?

Why are my Swing applications not closing when using Netbeans 6.5 on Ubuntu 8.10 with Sun JDK 6. Even the Netbeans tutorials downloaded from the Netbeans website do the same. When I close the application I'm left with a dead window. I then have to manually kill the process. It comes and goes, but I can't figure out what triggers this behavior.
I have also run my applications from the command line terminal using openjdk (6b12-0ubuntu6.1) and sun-java (6-10-0ubuntu2), still no luck. I have noticed when running it through netbeans after trying to close it netbeans still shows the app as running and after manually killing the process my netbeans log prints "Java Result: 137"
Update - 4Mar: I have also tried upgrading to Sun JDK 6u12 and Netbeans 6.7m2. But still no luck.
Update - 4Mar: Ok, after further testing I found that this behavior starts as soon as I add JPA to my application. That makes explains why the JPA tutorial examples on the netbeans website also do the same. I have tried writing an ExitListener to first close the EntityManager but no luck yet. If I delete the EntityManager, Query and List from my Form Panel the applications closes properly again.
make sure you call setDefaultCLoseOperation(JFrame.EXIT_ON_CLOSE);
What minor release of Java 6 are you using?
I was on update 10 I think and having a lot of issues on Ubuntu 8.10, upgrading to .12 helped a lot.
This is caused by using the "System Default" or "GTKLookAndFeel" look and feel. I switched over to "NimbusLookAndFeel" and the issue disappeared.
I have tried all suggestions including Netbeans 6.7 and Java 6.12.
Still unclear as to why this is happening on Ubuntu 8.10.

Categories

Resources