从Eclipse启动时创建新的JFrame时,Java正在关闭。没有异常抛出 [英] Java is shutting down when creating a new JFrame when started from Eclipse. No exception thrown

查看:276
本文介绍了从Eclipse启动时创建新的JFrame时,Java正在关闭。没有异常抛出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个我正在Eclipse中开发的Java项目。直到今天一切都很好。昨天在完成我的项目工作之前,我最后一次运行它来检查一切是否正常并且运行正常。但今天当我启动项目并按下运行我的应用程序时,只是关闭(没有崩溃,没有消息,没有)。我追溯了这个问题,事实证明问题是新的JFrame(),当它被调用时它会关闭应用程序。

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在同一个项目中创建了一个测试类,你可以在下面看到:

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永远不会显示!

另一方面,如果我创建一个全新的项目并且我复制粘贴该类,则输出就像它一样应该是:

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

我尝试更改默认JRE,清除bin文件夹等等。

I tried changing the default JRE, clearing the bin folder, and so on.

到目前为止唯一可行的解​​决方法是从我的类路径中删除随机JAR。我的项目类路径中总共有16个JAR。但是,如果我随机删除一些theese JAR,那么它开始工作,当然完全打破了我的项目。删除JAR后我删除了什么并不重要。删除了一些它开始工作。

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

一个奇怪的事情是如果我将我的代码编译成一个JAR文件并从CMD运行它,Swing正常启动,我的应用程序按预期工作。 AB正确显示。所以它必须与Eclipse相关。但我今天还没有更新任何东西。 (我昨天晚上只更新了我的Nvidia GPU驱动程序,但这与Eclipse完全无关。)

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.

推荐答案

我的情况完全相同。

我的代码在创建JFrame时在swing类中崩溃,没有抛出异常。测试代码如下所示

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();
    }
  }    
}

在我的工作区中有2个带有swing GUI的项目。更简单的一个工作,因为它应该更复杂的一个崩溃JFrame创建。

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.

在进一步调查期间,我发现当一定数量的图书馆(在我的情况下为19-22)包括在内时,项目开始崩溃建立路径。它不依赖于构建路径或类型中的jar大小。没有明确的逻辑,它停止工作的罐子。

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.

长篇小说我发现Windows日记中的崩溃原因是它的NVIDIA 3D Vision驱动程序! 3DVision驱动程序卸载后所有工作正常(不需要卸载显示驱动程序只有3D Vision导致问题)。我安装了最新的(v378.49)GeForce驱动程序。有一个与此错误相关的Windows日记条目的粗略翻译:

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

这篇关于从Eclipse启动时创建新的JFrame时,Java正在关闭。没有异常抛出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆