Utilising Payload is very simple.
The chief reason for Payload is to create environment dependent install files. When deployed to a machine, a .properties file on the machine is used to configure the install file for that machine. This is how that may be done.
org.osjava.payload=true
org.osjava.payload.interpolate.endsWith=txt
org.osjava.payload.interpolate.endsWith=xml
org.osjava.payload.interpolate.matches=regexp
org.osjava.payload.interpolate.archive.endsWith=war
org.osjava.payload.interpolate.archive.matches=regexp
This specifies which files are interpolated. It also specifies that any .war files should have their constituent files interpolated too.
VARIABLE=A value for the variable
PORT=8080
IP=127.0.0.1
and the jar'd files should contain ${VARIABLE}, ${PORT} and ${IP}.
Sometimes a payload extraction with search and replace is not enough to create the right system. Paylets are a way to send Java code along with the self-extracting jar to provide custom functionality. They are executed after the extraction has occured, and have access to all available parameters.
Including a paylet is quite basic:
org.osjava.payload.Paylet interface.
org.osjava.payload=true
org.osjava.payload.paylet=com.example.ExamplePaylet
This hooks in one example paylet. Many paylets may be hooked in, for example:
org.osjava.payload=true
org.osjava.payload.paylet=com.example.ExamplePaylet
org.osjava.payload.paylet=com.example.TestPaylet
org.osjava.payload.paylet=com.example.ObfuscatePaylet