Getting Started without an IDE

This guide shows how to kick-start a TrueVFS application in a command line shell with the help of a Maven archetype.

Prerequisites

You need to have the following software installed:

Generating a Sample Project

To generate a sample project, type the following command in a shell, thereby customizing the value of the properties groupId, artifactId and package to meet your requirements:

$ mvn archetype:generate -B \
    -DarchetypeGroupId=net.java.truevfs \
    -DarchetypeArtifactId=truevfs-archetype-access \
    -DarchetypeVersion=0.12.0 \
    -DgroupId=com.company \
    -DartifactId=project \
    -Dversion=0.1-SNAPSHOT \
    -Dpackage=com.company.project

Upon successful execution, a new directory with the value of the property artifactId as its name will have been created in the current directory. If you copy/paste the above command literally to a shell this would result in the following directory structure:

project
|-- pom.xml
`-- src
    `-- main
        `-- java
            `-- com
                `-- company
                    `-- project
                        |-- Application.java
                        |-- Cat.java
                        |-- Copy.java
                        |-- Pickr.java
                        `-- Tree.java

Exploring the Sample Project

The project directory contains the following files:

pom.xml
This is the Maven Project Object Model (POM). The POM declares the properties of your project to Maven so that it can build, install and run it. Within the <project>/<dependencies> element is the declaration of the dependencies of your application, i.e. the JARs required to compile and run it. Each file system driver module on the run time class path adds to the initial file system driver mapping for use by the TrueVFS Access module, so please edit it later to meet your requirements.
src/main/(java|scala)/com/company/project/(java|scala)/Application.java
This abstract base class runs the setup-work-sync life cycle of a typical TrueVFS application. You may want to uncomment its sync() method in order to sleep forever instead of calling TVFS.umount() so that you have a chance to use the JMX interface of the module TrueVFS Extension Insight before the short lived sample applications terminate.
src/main/java/com/company/project/java/(file|path)/Cat*.java
These command line utilities recursively copy their file arguments to the standard output. If you name any archive file entries in the arguments, they get copied, too.

For example, if the JAR for the module truevfs-driver-zip is locatable on the class path at run time, you could use the argument archive.zip/readme.txt to print the contents of the entry readme.txt in the archive file archive.zip.

src/main/java/com/company/project/java/(file|path)/Copy.java
This command line utility recursively copies its first file or directory argument to its second file or directory argument. Instead of a directory, you can name any configured archive file type in the path names, too. If you name any archive files in the destination path name, they get automatically created.

For example, if the JAR for the module truevfs-driver-zip is locatable on the class path at run time and the destination path name is archive.zip, a ZIP file with this name gets created unless it already exists.

src/main/java/com/company/project/java/file/Pickr.java
This utility lets you pick a file using a TFileChooser and prints it's path to standard output. Of course, TFileChooser can browse archive files, too.

For example, if the JAR for the module truevfs-driver-zip is locatable on the class path at run time and a ZIP file archive.zip exists, then you can double click it to browse its entries.

src/main/(java|scala)/com/company/project/(java|scala)/(file|path)/Tree.java
This command line utility prints the tree graph of the directory structure of its file or directory arguments to the standard output. Instead of a directory, you can name any configured archive file type as an argument, too.

For example, if the JAR for the module truevfs-driver-zip is locatable on the class path at run time and the path name argument is archive.zip and this file actually exists as a ZIP file, then the tree graph of the directory structure of this ZIP file gets printed.

src/main/java/com/company/project/java/diagnostics/DriverMap2Html.java
This command line utility pretty-prints a map of file system drivers to an HTML table. You can use its main method to diagnose the class path setup or document custom file system driver map modifier implementations.

For example if you run the main method of this class without parameters, it will print a HTML table with all file system driver mappings which result from locating, instantiating and applying all file system driver map modifier implementations on the class path.

Build And Run Your Application

To build and install your application in your local Maven repository, enter:

$ cd project
$ mvn clean install

Close to the end of the output of the Maven command, it should read [INFO] BUILD SUCCESS:

To run the main class Tree, enter:

$ mvn exec:java -Dexec.mainClass=com.company.project.Tree

This should produce a similar output to the following in the Console view:

.
|-- pom.xml
|-- src
|   `-- main
|       `-- java
|           `-- com
|               `-- company
|                   `-- project
|                       |-- Application.java
|                       |-- Cat.java
|                       |-- Copy.java
|                       |-- Pickr.java
|                       `-- Tree.java
`-- target
    |-- classes
    |   `-- com
    |       `-- company
    |           `-- project
    |               |-- Application.class
    |               |-- Cat.class
    |               |-- Copy.class
    |               |-- Pickr.class
    |               `-- Tree.class
    |-- generated-sources
    |   `-- annotations
    |-- maven-archiver
    |   `-- pom.properties
    |-- project-0.1-SNAPSHOT.jar
    |   |-- META-INF
    |   |   |-- MANIFEST.MF
    |   |   `-- maven
    |   |       `-- com.company
    |   |           `-- project
    |   |               |-- pom.xml
    |   |               `-- pom.properties
    |   `-- com
    |       `-- company
    |           `-- project
    |               |-- Application.class
    |               |-- Cat.class
    |               |-- Copy.class
    |               |-- Pickr.class
    |               `-- Tree.class
    `-- surefire

Note that the contents of the JAR file target/project-0.1-SNAPSHOT.jar get listed, too! This is because the configuration file pom.xml is set up to recognize JAR files as virtual directories by adding the module TrueVFS Driver ZIP with the artifactId truevfs-driver-zip to the run time class path. You can change this by editing the configuration file pom.xml.