Jackles Jackles - 6 months ago 16
Java Question

Java JAR behaving differently to program run out of IDE

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.

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?

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

Answer

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

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

java -version

is the same as in netbeans.

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