Java JAR的行为不同于IDE中的程序运行 [英] Java JAR behaving differently to program run out of IDE

查看:95
本文介绍了Java JAR的行为不同于IDE中的程序运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我一直在用netbeans做一个聊天客户端,我已经做完了。
我决定清理并构建以对其进行独立测试。

Ok, so I have been making a chat client in netbeans and I'm pretty much done. I decided to clean and build to test it standalone.

但是,当使用套接字从另一个程序接收到消息时(连接正常),程序关闭。直接在IDE中运行该问题从未发生过。

However, when a message is received from the other program using sockets (Connection goes fine), the program closes. This issue never occurred when it was run straight from the IDE.

因此,我想知道的是程序的行为是否不同(显然,行为如何,但是如何?)一旦清洗干净并装入罐子中。还有什么我必须考虑的。

So, what I am wondering is whether the program behaves differently(well it obviously does, but how?) once it is clean and built into a jar. Is there something extra I must take into account. Such as does an exception mean it will all suddenly cease?

此外,由于它仅在内置的jar中发生,因此我看不到任何可能发生的异常。我很沮丧...

Also, since it only occurs with the built jar I cannot see any exceptions that may have occurred. I am very stumped...

推荐答案

主要区别在于运行目录,即您所使用的Java的特定版本使用和命令行选项。

The main differences will be the directory it is run from, the specific version of Java you use and the command line options.

其中,最有可能导致问题的原因是运行不同版本的Java。我会检查

Of these, the most likely cause of a problem is running a different version of Java. I would check that

java -version

与netbeans相同。

is the same as in netbeans.

我也将从命令行运行JAR以确保您看到异常/产生了错误。

I would also run your JAR from the command line to ensure that you see an exceptions/error produced.

这篇关于Java JAR的行为不同于IDE中的程序运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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