java.net.URL working on Kaffe?

Stephen Crane jscrane at maths.tcd.ie
Mon Jan 11 15:43:00 PST 1999


Hi,
I've been trying, without much success, to write a small application
which pulls back web-pages and parses their content.  The code I'm
using to open the URL looks like this:

    URL url = null;
    try {
      url = new URL(ctxt);
    } catch (MalformedURLException e) {
      System.err.println (ctxt+": "+e);
    }
    if (url != null) {
      InputStream i = null;
      try {
        i = url.openStream ();
      } catch (IOException e) {
        System.err.println (ctxt+": "+e);
      }

I get the following error:
http://www.foo.com/: java.net.MalformedURLException: failed to find handler

Looking through the code for java.net.URL, I notice that this exception
is thrown by URL.getURLStreamHandler (called from URL.openStream via 
URL.openConnection).  

Since I haven't set an URLStreamHandlerFactory, I guess it's trying to use 
defaultFactory (kaffe.net.DefaultURLStreamHandlerFactory). This attempts to 
find a handler based on the protocol name (http) in kaffe/net/www/protocol. 
However, this directory contains only file and system handlers, no http 
(or ftp, telnet or mailto either for that matter).

My question is, (I suppose, as it appears that no handler for http has 
yet been implemented in Kaffe) has anyone else made this work (or worked
around it)?

I'm using 1.0b3.  I looked in yesterday's snapshot but kaffe/net/www/protocol
still contained no http subdirectory.

Thanks,
Steve
-- 
Stephen Crane, insomniac programmer, at home.


More information about the kaffe mailing list