469,592 Members | 2,041 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/net/ftp

107 100+
Hai All,

I am Having a problem in the following...

Expand|Select|Wrap|Line Numbers
  1. import org.apache.commons.net.ftp.FTPClient;
  2. import org.apache.commons.net.ftp.FTPFile;
  3. import org.apache.commons.io.FileUtils;
  4. import java.io.IOException;
  5.  
  6. public class Main {
  7.   public static void main(String[] args)throws Exception {
  8.     FTPClient client = new FTPClient();
  9.  
  10.     client.connect("ftp.myprojectplan.com");
  11.     client.login("myprojec_test@myprojectplan.com", "test123");
  12.  
  13.     String[] names = client.listNames();
  14.     for (String name : names) {
  15.       System.out.println("Name = " + name);
  16.     }
  17.  
  18.     FTPFile[] ftpFiles = client.listFiles();
  19.     for (FTPFile ftpFile : ftpFiles) {
  20.       if (ftpFile.getType() == FTPFile.FILE_TYPE) {
  21.         System.out.println("FTPFile: " + ftpFile.getName() + "; "
  22.             + FileUtils.byteCountToDisplaySize(ftpFile.getSize()));
  23.       }
  24.     }
  25.     client.logout();
  26.     client.disconnect();
  27.   }
  28. }
  29.  
  30.  
The error Shows Like

Expand|Select|Wrap|Line Numbers
  1. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/ne
  2. t/ftp/FTPClient
  3.         at Main.main(Main.java:8)
  4. Caused by: java.lang.ClassNotFoundException: org.apache.commons.net.ftp.FTPClien
  5. t
  6.         at java.net.URLClassLoader$1.run(Unknown Source)
  7.         at java.security.AccessController.doPrivileged(Native Method)
  8.         at java.net.URLClassLoader.findClass(Unknown Source)
  9.         at java.lang.ClassLoader.loadClass(Unknown Source)
  10.         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  11.         at java.lang.ClassLoader.loadClass(Unknown Source)
  12.         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
  13.         ... 1 more
  14.  
Mar 21 '10 #1
1 8892
Dheeraj Joshi
1,123 Expert 1GB
Did you set your class path properly?

Regards
Dheeraj Joshi
Mar 26 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by news | last post: by
oll3i
4 posts views Thread by oll3i | last post: by
9 posts views Thread by tiyaramunna | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.