1. create B.java: import java.io.*; import java.net.*;
public class B { public static void main(String[] args) { URL javacodingURL = null; try { javacodingURL = new URL(args[0]); System.out.println("protocol = " + javacodingURL.getProtocol()); System.out.println("host = " + javacodingURL.getHost()); System.out.println("filename = " + javacodingURL.getFile()); System.out.println("port = " + javacodingURL.getPort()); }catch(MalformedURLException e){ // Malformed URL System.out.println("Error in given URL"); return; } try { URLConnection connection = javacodingURL.openConnection(); System.out.println("conn="+connection); System.out.println(connection.getContentType()); BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line = ""; while ((line = br.readLine()) != null) System.out.println(line); br.close(); }catch(UnknownHostException e){ System.out.println("Unknown Host"); return; }catch(IOException e){ System.out.println("Error in opening URLConnection, Reading or Writing"); return; } } } 2. Compile it: gcj -fjni --main=B B.java 3. Run it: ./a.out http://www.opendesktop.net The output is: protocol = http host = www.opendesktop.net filename = port = -1 conn=gnu.gcj.protocol.http.Connection:http://www.opendesktop.net null Error in opening URLConnection, Reading or Writing Error happened. But, if you compile B.java with javac, then run java B http://www.opendesktop.net The output is OK, no error happened. And I also found that when you run like this: ./a.out http://www.opendesktop.net/ The output is also OK. I think the URL and URLConnection class should be enhanced . -- Summary: the URL and URLConnection class should be enhanced Product: gcc Version: 3.3.3 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: zhsoft88 at sohu dot com CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19066