site :
  home page

about FinJ :
  online API
  what's next ?

miscellaneous :
  JUnit testing

resources :
  LGPL license


finj - mini-howto

[ L A S T   U P D A T E   :   2015-07-22 ]


This page will explain you how to get everything ready for a small demo of finj usage.

Once the simple demo is running, just edit it's source code to test more complexe features. Have a look to the API if you need ideas.

Do not hesitate to send me your comments or experiences with this mini-howto.

        -- javier


In order to get finj to work in your program, you need :

  • Java 2 Virtual Machine :
    Download, install, configure. Any version number larger that 1.2.x will make it.
    • Windows, Solaris and Linux users :
      download J2SE (Java 2 Plateform, Standard Edition) - for developpers - or JRE (Java 2 Runtime Machine) - virtual machine alone - from Sun Java official site (follow "products").
      Note that several other implementations are available, like IBM's, for example.
    • MacOS X users :
      have a Java 2 Virtual Machine installed by default.
    • MacOS 8.x, 9.x users :
      go to and have fun. If you get to understand something, just email me :)
  • finj :
    Sounds odd, doesn't it ? :)
    You can always get latest version of finj from sourceforge, on finj downloads page.
    finj is available in several packages :
    • finj-api :
      API doc alone.
      Doesn't contain any source code.
    • finj-bin :
      already compiled classes, ready to use !
      Will work with both J2SE and JRE.
    • finj-src :
      all source files, with a Makefile to recompile the whole project.
      Requires a full J2SE installation, JRE is not enough.
    • finj-i18n :
      internationalization files alone, for people that'd like to give a hand to the project.
      Contained in both finj-bin and finj-src packages.
  • setup :
    After downloading finj-bin_?.jar - where '?' is the version number - just copy it to the jre/lib/ext/ directory that can be found in the directory where you've installed the Java 2 Virtual Machine.

That's all, folks !

Simple demo code

If you've taken the steps above, compiling the demo program is just a question of typing at a prompt :

% javac

running it will be done by typing at a prompt :

% java FTPSimpleDemo <server> <user> <password>

where server, user and password match with valid FTP server name (or IP address) and valid user identification data for this server.

Contents of (for the lazy ones, here is the compiled class) :

import org.finj.FTPClient;

 * Just a small demo class to show how to use <CODE>finj</CODE>'s 
 * in a really basic way.
 * @author Javier Iglesias -- 
 * @version v1.0
public class FTPSimpleDemo extends Object {

   * Constructs a new instance of <CODE>org.finj.FTPClient</CODE>, 
   * then tries to connect to the <CODE>server</CODE>, identifying  
   * the <CODE>user</CODE> with <CODE>password</CODE>, 
   * and finally prints to <CODE>System.out</CODE> the contents 
   * of the default directory (that MAY be EMPTY!).
   * @param server computer name or IP address to connect.
   * @param user   username to use when login.
   * @param passwd password to use when login.
  public FTPSimpleDemo ( String server, 
                         String user, 
                         char[] password ) throws Exception {
    FTPClient client = new FTPClient();

    // connect to the server;
    client.login(user, password);

    // get directory contents
    String[] names = client.getFileNames();
    System.out.println("Contents of directory '" + 
                       client.getWorkingDirectory() + 
    for ( int index = 0;
          index < names.length;
          index ++ ) {
      System.out.println("   NAME n" + 
                         (index+1) + 
                         " -> " + 

    // gracefully close connection

   * Method that lauches the test. If no parameters are provided, it 
   * prints a "Usage" message.
   * @param args list of arguments provided on the command line.
  public static void main ( String[] args ) throws Exception {
    if ( args.length < 3 ) {
      System.out.println("Usage : java FTPSimpleDemo <server> <user> <password>");
    new FTPSimpleDemo(args[0], args[1], args[2].toCharArray());


forged on     written with     tested using
SourceForge Logo   JUnit logo   JUnit logo

project admin