Apache Commons logo Commons VFS

About Apache Commons VFS Examples

This example module contains sample source code for learning how to use Apache Commons VFS in the org.apache.commons.vfs2.example package.

The org.apache.commons.vfs2.libcheck package contains some Java classes to exercise some of the functionality of the libraries (dependencies) used by Apache Commons VFS. This is mainly for the maintainers of VFS providers.

Commons VFS Shell Example

The Commons VFS Shell is an example for a command line shell. It can be used to play with different providers and to verify an installation.

Check out the page VfsExampleShell on the Apache Commons Wiki for a number of examples. In particular you can use the info command to list the schemes which are auto discovered by the StandardFileSystemManager.

The following examples assume an environment variable REP which points to a populated local Maven repository. As an alternative you can download the required dependencies manually. (The commons-collection4 dependency is not needed for the VFS Shell as it does not use LRUFilesCache.) Because of licensing restrictions the sandbox component must be built locally and then installed into the repository.

Starting VFS Shell on Linux/Unix

REP=~/.m2/repository
LIB=$REP/commons-logging/commons-logging/1.2/commons-logging-1.2.jar
LIB=$LIB:$REP/commons-net/commons-net/2.2/commons-net-2.2.jar
# LIB=$LIB:$REP/org/apache/commons/commons-collections4/4.0/commons-collection-4.0.jar
LIB=$LIB:$REP/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar:$REP/commons-codec/commons-codec/1.2/commons-codec-1.2.jar
LIB=$LIB:$REP/com/jcraft/jsch/0.1.51/jsch-0.1.51.jar
# next 3 lines are for webdav
LIB=$LIB:$REP/org/apache/jackrabbit/jackrabbit-webdav/1.6.5/jackrabbit-webdav-1.6.5.jar
LIB=$LIB:$REP/org/slf4j/slf4j-api/1.5.11/slf4j-api-1.5.11.jar:$REP/org/slf4j/slf4j-simple/1.5.3/slf4j-simple-1.5.3.jar
LIB=$LIB:$REP/org/apache/jackrabbit/jackrabbit-jcr-commons/1.6.5/jackrabbit-jcr-commons-1.6.5.jar
# LIB=$LIB:$REP/org/apache/commons/commons-vfs2-sandbox/2.1/commons-vfs2-sandbox-2.1.jar:$REP/jcifs/jcifs/0.8.3/jcifs-0.8.3.jar
LIB=$LIB:$REP/org/apache/commons/commons-vfs2-examples/2.1/commons-vfs2-examples-2.1.jar
LIB=$LIB:$REP/org/apache/commons/commons-vfs2/2.1/commons-vfs2-2.1.jar
java -cp $LIB org.apache.commons.vfs2.example.Shell

Starting VFS Shell on Windows

set REP=%USERPROFILE%\.m2\repository
set LIB=%REP%\commons-logging\commons-logging\1.2\commons-logging-1.2.jar
set LIB=%LIB%;%REP%\commons-net\commons-net\2.2\commons-net-2.2.jar
REM # set LIB=%LIB%;%REP%\org\apache\commons\commons-collections4\4.0\commons-collection-4.0.jar
set LIB=%LIB%;%REP%\commons-httpclient\commons-httpclient\3.1\commons-httpclient-3.1.jar;%REP%\commons-codec\commons-codec\1.2\commons-codec-1.2.jar
set LIB=%LIB%;%REP%\com\jcraft\jsch\0.1.51\jsch-0.1.51.jar
REM # next 3 lines are for webdav
set LIB=%LIB%;%REP%\org\apache\jackrabbit\jackrabbit-webdav\1.6.5\jackrabbit-webdav-1.6.5.jar
set LIB=%LIB%;%REP%\org\slf4j\slf4j-api\1.5.11\slf4j-api-1.5.11.jar;%REP%\org\slf4j\slf4j-simple\1.5.3\slf4j-simple-1.5.3.jar
set LIB=%LIB%;%REP%\org\apache\jackrabbit\jackrabbit-jcr-commons\1.6.5\jackrabbit-jcr-commons-1.6.5.jar
REM # set LIB=%LIB%;%REP%\org\apache\commons\commons-vfs2-sandbox\2.1\commons-vfs2-sandbox-2.1.jar;%REP%\jcifs\jcifs\0.8.3\jcifs-0.8.3.jar
set LIB=%LIB%;%REP%\org\apache\commons\commons-vfs2-examples\2.1\commons-vfs2-examples-2.1.jar
set LIB=%LIB%;%REP%\org\apache\commons\commons-vfs2\2.1\commons-vfs2-2.1.jar
java -cp %LIB% org.apache.commons.vfs2.example.Shell