Reputation: 633
I'm working on a Java project that I'm developing in Eclipse. Till today everything was fine. Yesterday before finishing working on my project I run it one last time to check if everything is OK and it was running correctly. But today when I fired up the project and pressed "Run" my app misterously just closes (No crashes, no messages, nothing). I traced back the issue and it turns out that the issue is "new JFrame()" when called it just closes the app.
I created a test class in the same project, you can see it below:
import javax.swing.JFrame;
public class asdasd {
public static void main(String[] args) {
System.out.println("A");
try{
JFrame frame = new JFrame();
}catch(Exception e){
e.printStackTrace();
}
System.out.println("B");
}
}
When I run this code the console just outputs:
A
B is never shown!
On the other hand, if I create a completely new project and I copy paste that class the output is as it should be:
A
B
I tried changing the default JRE, clearing the bin folder, and so on.
The only working fix so far is to remove random JARs from my class path. I have 16 JARs in total in my projects class path. But if I remove randomly some of theese JARs then it starts working, breaking completely my project of course. It doesn't matters what JARs I remove, after removing some amount of them it starts working.
Things I tried so far: - Remove all Classes in my project leaving only the test class = Same Result - Create a fresh project, copy-paste all my classes and dependencies = Same Result
One curious thing is that if I compile my code into a JAR file and run it from the CMD, Swing starts normally and my app works as expected. AB is shown correctly. So it must be something Eclipse related. But I haven't updated anything for it to brake today. (I only updated my Nvidia GPU Drivers yesterday night, but that is completely unrelated to Eclipse).
Anybody has an idea what could be causing this issue? Thanks.
Upvotes: 2
Views: 625
Reputation: 382
I had absolutely identical situation.
My code crashed inside swing Window class during JFrame creation with no exceptions thrown. Test code looks like this
import javax.swing.JFrame;
public class MainPanel {
/** A Start point of the BC UI Clien Application. */
public static void main(String[] args) {
try {
JFrame objLoginPane = new JFrame();
objLoginPane.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
objLoginPane.pack();
objLoginPane.show();
} catch (Throwable ex) {
ex.printStackTrace();
}
}
}
In my workspace there was 2 projects with swing GUI. More simple one worked as it should more complex one crashed on JFrame creation.
In new workspace situation was the same. Solution above did not helped.
During further investigation I've figured out that the project began to crash when certain amount of libraries (19-22 in my case) included in build path. It was not depend on size of jars in build path or type. There was no clear logic with what jars it stops to work.
So long story short I've found the crash reason in windows journals it's NVIDIA 3D Vision Driver! After 3DVision driver uninstall all works fine (it is not required to uninstall display driver only 3D Vision cause the problem). I have latest (v378.49) GeForce drivers installed. There is my rough translation of windows journal entry related to this error:
Failed module name: nvSCPAPI64.dll, version: 7.17.13.7849, time stamp: 0x588218a5
Error code: 0xc0000409
Error offset: 0x0000000000034b2f
Failed process identifier: 0x143c
Failed process start time: 0x01d280cd39a31077
Failed process path: C:\Program Files\Java\jdk1.8.0_121\bin\javaw.exe
Failed module path: C:\Program Files (x86)\NVIDIA Corporation\3D Vision\nvSCPAPI64.dll
Report identifier: 6dd65788-acb1-48ce-a786-4e38af325fec
Upvotes: 2
Reputation: 633
So I finally found a working solution for me. I created a completely new Eclipse Workspace and copy-pasted all my classes. This seems to have fixed the unknown issue. I still don't know what caused the issue, but I hope it won't happen again.
This is not a real solution but more a workaround. I guess the best way would be to use Version Control as @efekctive suggested.
Thanks everyone to have provided suggestions on how to approach this issue.
Upvotes: 2