0

In my application I want to upload video using ftp. I included apache.commons.net library in my application. When I am running the code it shows 04-28 14:56:05.229: ERROR/dalvikvm(739): Could not find class 'org.apache.commons.net.ftp.FTPClient', referenced from method net.jeema.hwdvideoshare.NewVideoActivity$loadVideo.doInBackground.

How to solve this problem? I am using the below code:

protected Void doInBackground(Void... arg0) {
        String hostName = "ftp.host.net";
        String username = "test";
        String password = "test";
        String location = selectedPath;


        InputStream in = null;
        try {
            FTPClient ftp = new FTPClient();
            ftp.connect(hostName);
            ftp.login(username, password);

            ftp.setFileType(FTP.BINARY_FILE_TYPE);

            ftp.changeWorkingDirectory("/uploads");

            int reply = ftp.getReplyCode();
            System.out.println("Received Reply from FTP Connection:" + reply);

            if (FTPReply.isPositiveCompletion(reply)) {
                System.out.println("Connected Success");
            }

            File f1 = new File(location);
            in = new FileInputStream(f1);

            ftp.storeFile(fname, in);

            System.out.println("SUCCESS");

            ftp.logout();
            ftp.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
4

1 回答 1

0

当您链接 de lib 时,您是否必须引用它,并将其标记为可用的。

也许您忘记了这两个步骤之一?

打开应用程序的属性对话框,导航到“Java Build Path”->“Libraries”并添加引用。导航到“Java Build Path”->“Order and Export”并选择导出这两个jar。

于 2012-07-11T12:47:29.913 回答