Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-28-2009, 11:37 AM
Member
 
Join Date: Nov 2009
Posts: 1
Rep Power: 0
metoda is on a distinguished road
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:
Code:
package ftpupload;
import java.io.File;
import org.apache.commons.net.ftp.FTPClient;

public class Main {
    public static void main(String[] args) {
   
    int i=0;

    try{
        FTPClient fcl= new FTPClient();
        fcl.connect("ftp.nazwaserwera.pl");
        fcl.login("user", "password");
        String[] files = fcl.listNames();
        System.out.println(fcl.getStatus());
        while(i<files.length){
                System.out.println(files[i]);
                i++;
        }
        fcl.logout();
    }
    catch (Exception E) {
      System.err.println(E.getMessage());
    }
    }
}
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
t/ftp/FTPClient
Caused by: java.lang.ClassNotFoundException: org.apache.commons.net.ftp.FTPClien
t
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-28-2009, 06:19 PM
sky sky is offline
Member
 
Join Date: Nov 2009
Posts: 84
Rep Power: 0
sky is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
apache commons vfs delete directory with dependancies turanan New To Java 0 06-16-2009 04:35 PM
FTP private directory problems with org.apache.commons.net.ftp.FTP magaupe Advanced Java 0 09-13-2008 08:58 PM
Problems with ftp, commons library jurka Networking 0 09-01-2008 06:46 PM
Commons Library Framework 0.8.0 JavaBean Java Announcements 0 10-02-2007 05:13 PM
Commons validator aczuczor Web Frameworks 0 07-27-2007 09:46 AM


All times are GMT +2. The time now is 03:40 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org