Reputation: 27
I developped a small Gui application that downloads log files from a remote server. The Application works fine if I start it from within the Netbeans IDE 7.2 (no connection problems)
But if I start it as a standalone jar file, I get a socket exception indicating that the network is not reachable.
The code that creates the connection is as follows:
...
CookieManager manager = new CookieManager();
manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(manager);
URL url = new URL(logFileRemotePath);
URLConnection conn = url.openConnection();
InputStream input = conn.getInputStream();
...
The exception received is:
java.net.SocketException: Network is unreachable: connect
Any Ideas
Thanks in advance
Upvotes: 0
Views: 1791
Reputation: 2494
If your operating system has a firewall running, it is possible that it is configured in a way, that it allows network access from Netbeans, but not from executing a jar.
Do you get the exception instantaneously or after a normal timeout period? If it's the former, it means some component between your application and the network resource is immediately resetting your connection - for example some firewall.
Upvotes: 2