# SOS! URL can not work in Linux!

ZXS (xuesong.zhou@gte.net)
Wed, 17 Mar 1999 00:05:16 -0800

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Souza, Marise D: "Qs.."
- Previous message: (no name): "Message from mail server"

    Date: Wed, 17 Mar 1999 00:05:16 -0800

    From: ZXS <xuesong.zhou@gte.net>

    To: java-security@java.sun.com

    Subject: SOS! URL can not work in Linux!

Dear Sir.

I don't know why when my program try to initialize a URL object in
linux, it always doesn't work!
But I can ping and telnet by same linux server.

the Exception is MalFormedURLException: no host.

Did you know if there are any security limitation of linux for java?
Please help me!

The program I wrote as following:

import java.net.*;
import java.io.*;

public class URLDemo
{
public static void main(String args[]) throws Exception
{
try
{
// Check to see that a command parameter was entered
if (args.length != 1)
{
// Print message, pause, then exit
System.err.println ("Invalid command parameters");
System.in.read();
System.exit(0);
}

// Create an URL instance
URL url = new URL(args[0]);

// Get an input stream for reading
InputStream in = url.openStream();

// Create a buffered input stream for efficency
BufferedInputStream bufIn = new BufferedInputStream(in);

// Repeat until end of file
for (;;)
{
int data = bufIn.read();

// Check for EOF
if (data == -1)
break;
else
System.out.print ( (char) data);
}
}
catch (MalformedURLException mue)
{
System.out.println (mue);
}
catch (IOException ioe)
{
System.out.println ("I/O Error - " + ioe);
}
}
}

This is simple program and can work in my PC, but when I transfer it
to linux
server, it can not works.

when I put the command like:"java URLDemo http://www.yahoo.com"
The Exception is"no host"

There are two network cards in this linux server, one is
216.101.18.14,
connects to ISP's ADSL card-216.101.18.254; Another card is
connected to out LAN
that is 192.168.0.100. When I test in my pc, my localhost is
192.168.0.17.

I make another test program, and it found in linux, localhost is
192.168.0.100
but whatever you input any URL, the destination host IP still is
216.101.18.14!

Who can help me! I have involved in this trouble for two weeks!
Thank you all!

- Next message: Souza, Marise D: "Qs.."
- Previous message: (no name): "Message from mail server"