I am new to Java, have searched on the net and this forum but unable to figure out why my code is not compiling? Any help will be highly appreciated.
//filename is TestHTTPConnection.java
class TestHTTPConnection {
public static void main (String[] args){
String strUrl = "http://abc.com";
try {
URL url = new URL(strUrl);
URLConnection Conn = url.openConnection();
Conn.connect();
assertEquals(URLConnection.HTTP_OK, Conn.getResponseCode());
} catch (IOException e) {
System.err.println("Error creating HTTP connection");
e.printStackTrace();
throw e;
}
}
}
Compilation error - complains about "URL", "URLConnection" and "IOException".