Orangevolt ANT Tasks » Tasks » sfx
sfxDynamic commandline example

2.1.1.  Example

Suppose an sample application named layxx with the following directory structure

bin/
  layxx.bat
  layxx.sh
lib/
  layxx.jar
  common.jar
native/
  common.dll
  common.so
doc/
  index.html

  1. Zip the directory structure to an archive (layxx.zip for example).

  2. Create a Ant make file with the following content:

    build.xml
    <?xml version="1.0"?>  
     
    <project basedir="." name="layxx" default="sfx">
      <taskdef classpath="orangevolt-ant-tasks-1.3.2.jar" resource="com/orangevolt/tools/ant/taskdefs.properties"/>
        
      <target name="sfx">
          <!-- create windows executable -->
        <sfx
        archive="layxx.zip"
        mode="win32"
        workingDirectory="/bin"
        execute="hello.bat"
        output="layxx.exe"
      />
            <!-- create windows console executable -->
      <sfx
        archive="layxx.zip"
        mode="win32-console"
        workingDirectory="bin"
        execute="layxx.bat"
        output="layxx-console.exe"
      />
        <!-- create unix executable -->
      <sfx
        archive="layxx.zip"
        mode="unix"
        workingDirectory="/bin"
        execute="layxx.sh"
        output="layxx"
      />
        <!-- create java console executable -->
      <sfx
        archive="layxx.zip"
        mode="java-console"
        execute="javaw -jar layxx-console.jar"
        output="layxx-console.jar"
      />
            <!-- create java executable -->
      <sfx
        archive="layxx.zip"
        mode="java"
        execute="javaw -jar layxx.jar"
        output="layxx.jar"
      />
      </target>
    </project>

Thats it. After running Ant you have 5 exectables created by sfx.

When starting the windows executable created by this example the contents of the executable are extracted to [temp-dir]/layxx.exe, the current directory is set to [temp-dir]/layxx.exe/bin and layxx.bat will be started.

As you can see in the example you don't really need to create start scripts for your application. It is also possible to pack the whole start command into the execute attribute.

Attention windows exececutable creators : The created java jar files are only working successfully when started from command line. Otherwise the current working directory is not known and the archive cannot extract itself.