Java GUI not displaying in eclipse on Ubuntu - java

I'm working on a GUI program written in Java (using Swing) in Eclipse. I usually develop on Windows, and I am able to run\debug the program in Eclipse and it displays just fine. (I'm using a JUnit test to run the different windows of the GUI program).
However, I recently put Ubuntu on my machine on a second partition on my hard drive, installed Eclipse, and tried to run the JUnit test, but the GUI window appears for a second then disappears. The rest of the JUnit test runs just fine, (0 errors, 0 failures) but I can't see the GUI. Anyone know why this would happen? Thanks.

Ok, I figured it out. GUIs aren't meant to be run in JUnit tests, because as soon as the tests are completed, the program will exit, and the GUI will immediately close. For some reason, the program was staying open when I ran the JUnit test in Windows, but that's not really supposed to happen.
Because, in the current project that I'm working on, it makes more sense for me to open the GUI in a JUnit test, I implemented the following workaround: I had the method that ran the GUI simply wait until the GUI is closed before it continued to execute. To do this, I used the mechanism described here.

Related

How to run a java application in windows like,how antivirus runs always

I have a run able jar of My own java application,but I want to make that application run in windows background process always instead of clicking every time to run it.How to do that?
One way to do it is use frame with minimum size and run everything there, pretty sure it's not the best method but it does the trick.

Eclipse : Creating and simultaneously running multiple test cases

I have written an application in Java using Eclipse Luna IDE. On paper I know the test cases required to test all branches/aspects of my application.
Does "eclipse alone" allow us to write test cases and execute it ?
I am specifically interested in being able to run all these tests cases in one click.
Something like this will help test the complete application with just onclick.

debugging changes result Java Eclipse

I'm wondering something about debugging and what it means.
Currently developping a program that watches a directory and when something changes in the directory, it runs all the tests that it can find in the same directory.
So, I test what happens if you change the tests? I find that when I have 20 tests that should fail, and I change one of them to succeed, the program finds and runs all the tests and reports 20 failed tests. It doesn't use the new test, which is slightly odd.
Now, when I go through the program with a debugger, it does detect the new test!
How come the results change when using a debugger? It is the default debugger of Eclipse.
The program watches the directory using a WatchService and runs and collects the tests using JUnit.
I shall answer your question as I understand it.
The debugger in eclipse is designed for making complex applications, like GUI's or apps like your own.
The debugger allows you to change the code of a program in real time. It is designed for you to be able to edit an application, and see what your doing with it, IE changing a window size, ETC.
Each debugger run is a clean build. Try cleaning the builds of your eclipse project, this may be creating the problem, as the compiler is logging the data and expecting you to input a certain answer.

Netbeans problems with reflection

Why Netbeans takes so much time in java.lang.Class.getDeclaredField(String)?
I have isolated my problem and I have two projects:
I created a Netbeans Platform program with one module that has one window and one button in it. So when I click it, program runs the function that I need.
I created a form that will call that function.
So now I have two programs that are the same and run from an AWT thread. The key difference is that one runs under Netbeans Platform structure and the other one is alone.
Profiling the two programs I found that the big problem is when it calls "java.lang.Class.getDeclaredField(String)" Netbeans program takes 30,784 ms and Swing program takes 2,055 ms
It seems to me that Netbeans has some sort of security that checks when somebody is trying to access a class through reflection.
Does anybody knows what is it? and how to turn it off??
Thanks
HS

The jar doesn't work properly... debugging post-build?

I'm in the dark as to how to even attack this particular problem and I have very little information to work with. Please bear with me.
My current project (a trading application) runs fine from Netbeans 6.9, and the build actually runs fine.. at first.. with `java -jar "my project.jar". It is a Swing application and everything comes up nicely. There are no error message in the terminal window.
However, when I engage the trading program itself (setting some of the threads into a more active state by clicking a command button), nothing happens. No error messages in the terminal, and none of the usual messages in the application. Like I said, it works fine from within Netbeans. Also, I've written other programs before using the same trading API (Interactive Brokers) and Swing, and haven't had this problem.
How do I even begin troubleshooting this problem?
I am admittedly build-stupid, meaning I have no idea how builds work and therefore no idea how to check if it is building properly.
I've checked /dist/lib and verified all of the libraries are present.
Thanks in advance for any suggestions.
Like Sean says, first check the JAR file to see if everything is there. Maybe the build is missing a file.
If that doesn't help, you can debug the application remotely. Here's a howto for Netbeans.
This happens because your Application is throwing an exception in the background. Try to execute your app using cmd:
java -jar yourappname.jar
You will see the exception in the cmd console, fix the exception and violá.
Best regards

Categories