Results 1 to 2 of 2
- 11-28-2009, 10:37 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 7
- Rep Power
- 0
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:
The problem apperas when I want to run this app in console outside NetBeans IDE.Java 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()); } } }
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.
- 11-28-2009, 05:19 PM #2
Member
- Join Date
- Nov 2009
- Posts
- 96
- Rep Power
- 0
Similar Threads
-
apache commons vfs delete directory with dependancies
By turanan in forum New To JavaReplies: 0Last Post: 06-16-2009, 03:35 PM -
FTP private directory problems with org.apache.commons.net.ftp.FTP
By magaupe in forum Advanced JavaReplies: 0Last Post: 09-13-2008, 07:58 PM -
Problems with ftp, commons library
By jurka in forum NetworkingReplies: 0Last Post: 09-01-2008, 05:46 PM -
Commons Library Framework 0.8.0
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-02-2007, 04:13 PM -
Commons validator
By aczuczor in forum Web FrameworksReplies: 0Last Post: 07-27-2007, 08:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks