Results 1 to 2 of 2
  1. #1
    metoda is offline Member
    Join Date
    Nov 2009
    Rep Power

    Unhappy small FTP app, commons-net-ftp, problems with run

    Hello. I am newbe Java programmer, as I have wrote my first java application two days ago, so be tolerant. I am using NetBeans IDE 6.7.1. I am writting small application, which is to connect with FTP server, and as a first step, it displays names of the files at the server. For this purpose I am using not standard library from Apache : commons-net-ftp-2.0.jar. This library has been installed properly. It is visible in NetBeans in Libraries section of teh project. Everything works fine.
    When I bulid Main Project, the file myfile.jar is build in folder "dist". When I try to run application by Run Main Project, everything works OK (I can connect to teh server and show the names of files.)
    This is my code:
    Java Code:
    package ftpupload;
    public class Main {
        public static void main(String[] args) {
        int i=0;
            FTPClient fcl= new FTPClient();
            fcl.login("user", "password");
            String[] files = fcl.listNames();
        catch (Exception E) {
    The problem apperas when I want to run this app in console outside NetBeans IDE.
    When I put(in the "dist" folder of the project): java -jar myfile.jar
    I get this message:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/ne
    Caused by: java.lang.ClassNotFoundException:
    at$ Source)
    at Method)
    at Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: ftpupload.Main. Program will exit.

    My main question:
    1.Can You tell me where the problem is ??

    I also wonder about some other things:
    2. Do I have to add manually not standard, as it works fine in NetBeans but not on the console ??
    3. How can I add this not standart library, so it will be possible to run this app on the machine, where this library is not installed ( only JVM present ).

    Thanks in advance, and sory for my english.
    Best regards from Poland.

  2. #2
    sky is offline Member
    Join Date
    Nov 2009
    Rep Power


    I'm just guessing, but maybe the library is only installed for NetBeans and it is not in the PATH of your operating system. So search in Google how to add non-standard librarys to Java.

Similar Threads

  1. Replies: 0
    Last Post: 06-16-2009, 03:35 PM
  2. Replies: 0
    Last Post: 09-13-2008, 07:58 PM
  3. Problems with ftp, commons library
    By jurka in forum Networking
    Replies: 0
    Last Post: 09-01-2008, 05:46 PM
  4. Commons Library Framework 0.8.0
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 10-02-2007, 04:13 PM
  5. Commons validator
    By aczuczor in forum Web Frameworks
    Replies: 0
    Last Post: 07-27-2007, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts