# java RemoteFile Exception: sun.net.ftp.FtpProtocolException: PORT :
When I execute this program, I keep getting an exception error about the port even though I specified port 21 in the URL. Any suggestions would be helpful on how to resolve this or a better approach to read the remote file.
That error has nothing to do with the FTP port (which is 21 by default, so you don't have to specify it). It has to do with the order in which commands are sent in the FTP protocol. I get that error when I hit my ISP's FTP server, which is Free BSD running WUFTP, but I don't get it when i hit ftp://cwrulug.cwru.edu, OS unknown, likely Linux. What OS/software combo are you using? You may want to look at Jakarta Commons Net Utilities. They have a more robust and open implementation of FTP.
What is the difference in the URL Class syntax to connect when using WU-FTP?
The URL class follows the format of a URL as specified by RFC 1738. The problem is not with the URL class syntax. It could be a couple of things. First, WUFTP doesn't support IPv6 sockets which Java uses by default. I tried using IPv4 by setting the java.net.preferIPv4Stack system property, but that didn't work. It could be that WUFTP has a problem with the EPSV site verb, since it's throwing an error code of 500 (unacceptable syntax). In any case, I recommend trying the Apache Commons Net library rather than trying to decypher what Sun's doing in its FTP client.