Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.7k views
in Java FTP by
The following code gives the error "Could not load class sun.io.ByteToCharUS-ASCII".

FTPClient ftp = new FTPClient();
ftp.setRemoteHost(FTPServer);
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener);
ftp.connect();
MessageBox.show("Connected to Server "+FTPServer);
ftp.login(FTPUsername, FTPPassword);
MessageBox.show("Logged in as "+FTPUsername);
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.quit();

Any ideas?

5 Answers

0 votes
by (162k points)
What does it do if you take the message boxes out?

The following code gives the error "Could not load class sun.io.ByteToCharUS-ASCII".

FTPClient ftp = new FTPClient();
ftp.setRemoteHost(FTPServer);
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener);
ftp.connect();
MessageBox.show("Connected to Server "+FTPServer);
ftp.login(FTPUsername, FTPPassword);
MessageBox.show("Logged in as "+FTPUsername);
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.quit();

Any ideas?
0 votes
by
I now only have a message box in the exception handler:

public void transferFiles()
{
try
{
//Enterprisedt.com code
FTPClient ftp = new FTPClient();
ftp.setRemoteHost(FTPServer);
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener);
ftp.connect();
ftp.login(FTPUsername, FTPPassword);
ftp.quit();
}
catch( Exception e )
{
MessageBox.show(e.toString());
}
}

And it the MessageBox Handler just prints out the Exception message:
java.io.UnsupportedEncodingException: US:ASCII[Could not load class: sun.io.ByteToCharUS-ASCII].

Now I checked and I don't have a sun.io.ByteToCharUS-ASCII class in sun.io - only a ByteToCharASCII. Maybe my version of Java isn't new enough? Can I get this Class from somewhere else?
0 votes
by (162k points)
What version of Java are you using? We've never heard of this error.

Could you try running the unchanged demo code that we distribute?

Now I checked and I don't have a sun.io.ByteToCharUS-ASCII class in sun.io - only a ByteToCharASCII. Maybe my version of Java isn't new enough? Can I get this Class from somewhere else?
0 votes
by
It is a very old one that came with Visual J++. I also have version 1.4.2 installed, and when I compile your Demo at the command line and run it, it works correctly.

But I can't get Visual J++ to use the most up-to-date version of Java, which means I am stuck with the old version (bad programming I know, but it is only a quick & dirty app).

So my question is, can I download the sun.io.ByteToCharUS-ASCII class from somewhere?
0 votes
by (162k points)
Sorry, all bets off with Visual J++. This is an internal Sun class BTW. I suppose you could download it but I'd be very surprised if you can get it to work with Visual J++.

So my question is, can I download the sun.io.ByteToCharUS-ASCII class from somewhere?

Categories

...