I have two java files or classes
One is a example called URLConnectionReader.java
that does:
import java.net.*;
import java.io.*;
public class URLConnectionReader {
public static void main(String[] args) throws Exception {
URL oracle = new URL("http://www.oracle.com/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
Second is Tester.java
with:
public class Tester extends URLConnectionReader {
public static void main(String []args){
URLConnectionReader.main(args);
}
}
All I wanted to do is execute, the main method in the URLConnectionReader.java
in the Tester.java main method?
I get this error "unreported exception Exception; must be caught or declared to be thrown"
I plan to use the Tester.java
as my main app and include various other methods or function.
What am I doing wrong here? It's frustrating as all the other examples are more complex code than this. I thought the "extend" will include the URLConnectionReader.class
into the Tester.class no?