[jnc-users] NullPointerException in HTTPUrlConnection
Status: Beta
Brought to you by:
soapy
From: Avi C. <av...@gm...> - 2008-05-27 18:31:30
|
Trying to compile a simple code that creates an HTTP connection: * import* java.net.URL; * import* java.net.URLConnection; * public* *class* PTest { *static* *public* *void* main(String[] args) { URLConnection conn = *null*; *try* { URL url = *new* URL("http://www.apache.org/"); conn = url.openConnection(); *if* (conn == *null*) { System.*out*.println("conn is null"); } conn.connect(); } *catch* (Exception ex) { ex.printStackTrace(); } } } Getting NPE in the connect() part: java.lang.NullPointerException at gnu.java.net.protocol.http.HTTPURLConnection.connect(PTest.exe) at PTest.main(PTest.exe) Any ideas ? using version 1.1.1, standard installation (other stuff work well). Running on XP SP2 and Vista. Thx, Avi |