Embedding FtpServer in 5 minutesFtpServer is designed to be easily embedded into your application. Getting a basic server up and running is as simple as FtpServer server = new FtpServer(); // start the server server.start(); To get this running, you need the following JAR files in your classpath:
Now, you will probably like to configure the server for your specific needs. For example, you might want to run on a non-privileged port to get around running as a root on Linux/Unix. To do that you need to configure a listener. Listeners are the part of FtpServer where network management is done. By default, a listener named "default" is created but you can add as many listeners as you like, for example to provide one for use outside of your firewall and one on the inside. Now, let's configure the port on which the default listener waits for connections. FtpServer server = new FtpServer(); // set the port of the default listener server.getListener("default").setPort(2121); // start the server server.start(); Now, let's make it possible for a client to use FTPS (FTP over SSL) for the default listener. FtpServer server = new FtpServer(); // set the port of the default listener server.getListener("default").setPort(2221); // define SSL configuration DefaultSslConfiguration ssl = new DefaultSslConfiguration(); ssl.setKeystoreFile(new File("mykeystore.jks")); ssl.setKeystorePassword("secret"); // set the SSL configuration for the listener server.getListener("default").setSslConfiguration(ssl); // start the server server.start(); There you have it, that's the basics that you usually need. For more advanced features, have a look at our configuration documentation. |