简体   繁体   English

Java应用程序停止,没有任何错误消息或异常

[英]Java application stops without any error message or exception

I am developing a Java application that runs fine on several hundred machines, both Windows and Linux (using latest Oracle JRE). 我正在开发一个Java应用程序,该应用程序可以在Windows和Linux的数百台计算机上正常运行(使用最新的Oracle JRE)。 However, on one Windows 7 64-bit machine the application won't run. 但是,在一台Windows 7 64位计算机上,该应用程序将无法运行。

Interesting fact: If started from command line via java -jar MyApp.jar then the application "just fails" and returns to the shell, without any message at all. 有趣的事实:如果通过java -jar MyApp.jar从命令行启动,则应用程序“只是失败”并返回到Shell,根本没有任何消息。

In order to find the problem I wrapped the whole content within main() like this: 为了找到问题,我将整个内容包装在main()如下所示:

public static void main(String [] args)
{
    try
    {
        // Init. Swing GUI, run application ...
    }
    catch(Throwable t)
    {
        t.printStackTrace();
        System.exit(1);
    }
}

Unfortunately, even with this try-catch block I still don't get any message on command line. 不幸的是,即使有了try-catch块,我仍然在命令行上没有收到任何消息。

Can you recommend any other ways for me to find out where the problem could be? 您能为我推荐其他方法来找出问题所在吗?

if possible enable debug method on that machine. 如果可能,请在该计算机上启用调试方法。 otherwise. 除此以外。 you may write some debug lines to a log file external to the jar. 您可以将一些调试行写入jar外部的日志文件中。 so that, you will know whether JVM calls the the main method or not. 这样,您将知道JVM是否调用main方法。 also try to check java version on that machine if your jar is depending on the specific jre on the windows 7 64 bit machine. 如果您的jar依赖于Windows 7 64位计算机上的特定jre,也请尝试检查该计算机上的Java版本。

It's possible that your application is running without an exception. 您的应用程序可能无例外地运行。 However, it's simply not rendering as expected. 但是,它根本无法按预期呈现。

One simple diagnostic should provide some more info. 一种简单的诊断应提供更多信息。 Add a "-verbose" switch to your command line. 在命令行中添加“ -verbose”开关。 That will print all the classes loaded during your application invocation. 这将打印在应用程序调用期间加载的所有类。

$> java -verbose -jar MyApp.jar

Should show some additional info. 应该显示一些其他信息。 Note! 注意! make sure you add -verbose as the first argument like I demoed above. 确保像我上面演示的那样,将-verbose添加为第一个参数。

Hopefully that get's you started. 希望这可以帮助您开始。

Also, you can add a System.out.println("SOME MESSAGE") as the first line in your try block. 另外,您可以将System.out.println(“ SOME MESSAGE”)添加为try块的第一行。 That might help also. 这可能也有帮助。

仅作记录:我们需要安装64位版本的JRE,现在该应用程序又像魅力一样工作了:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM