Orangevolt ANT Tasks » Tasks » jstub | ||
jstub | jnlp |
Suppose you have a working self executable jar file which is named myapp.jar.
build.xml |
|
<?xml version="1.0"?>
|
<project basedir= "." name= "myapp" default= "main" > |
<taskdef classpath= "orangevolt-ant-tasks-1.3.2.jar" resource= "com/orangevolt/tools/ant/taskdefs.properties" /> |
|
<target name= "main" > |
<jstub |
"myapp.jar" |
"win32" |
"java -jar myapp.exe" |
"myapp.exe" |
|
</target> |
</project> |
In case of a jar file which contains all resources required by your application named myapp.zip and is not a self executable jar file with main class com.mycompany.myapp you can use the following example.
build.xml |
|
<?xml version="1.0"?>
|
<project basedir= "." name= "myapp" default= "main" > |
<taskdef classpath= "orangevolt-ant-tasks-1.3.2.jar" resource= "com/orangevolt/tools/ant/taskdefs.properties" /> |
|
<target name= "main" > |
<jstub |
"myapp.jar" |
"win32" |
"java -cp myapp.exe com.mycompany.myapp" |
"myapp.exe" |
|
</target> |
</project> |
The example below uses the commandline placeholder XYZjstubLocationXYZ:
build.xml |
|
<?xml version="1.0"?>
|
<project basedir= "." name= "myapp" default= "main" > |
<taskdef classpath= "orangevolt-ant-tasks-1.3.2.jar" resource= "com/orangevolt/tools/ant/taskdefs.properties" /> |
|
<target name= "main" > |
<jstub |
"myapp.jar" |
"win32" |
"java -cp XYZjstubLocationXYZ com.mycompany.myapp" |
"myapp.exe" |
|
</target> |
</project> |
The key difference to the example before is that you can rename the application or put it somewhere in the path. The placeholder XYZjstubLocationXYZ will be replaced before execution by the real name and path of the executable.
An scenario: You rename the executable (configured with commandline javaw -cp XYZjstubLocationXYZ com.mycompany.myapp) to test.exe and store it under c:\winnt (which is registered in the PATH enviroment). When opening a console in c:\temp and execute test.exe the executable substitutes the placeolder and executes java -cp c:\winnt\test.exe com.mycompany.myapp.
Only the first placeholder will be replaced. Multiple placeholders will be ignored.This example shows how to create a unix executable using dynamic commandline substitution.
build.xml |
|
<?xml version="1.0"?>
|
<project basedir= "." name= "myapp" default= "main" > |
<taskdef classpath= "orangevolt-ant-tasks-1.3.2.jar" resource= "com/orangevolt/tools/ant/taskdefs.properties" /> |
|
<jstub output= "test.sh" mode= "unix" archive= "../layxx.jar" > |
<execute> |
|
</execute> |
</jstub> |
</project> |