It would be nice to have a script which simplified the task of installing and configuring the byteman agent when running a Java program. The requirements are as follows:
Syntax:
bmjava [-l rulescript | -b bootjar | -s sysjar | -nl | -nb | -nj ]* [--] javaargs
terms enclosed between [ ] are optional
terms separated by | are alternatives
a * means zero or more occurences
-l pass the file whose name follows this flag to the agent as
a rule script to be loaded during startup
-b pass the file whose name follows this flag to the agent as
a jar to be added to the bootstrap classpath
-s pass the file whose name follows this flag to the agent as
a jar to be added to the system classpath
-nl do not enable the agent listener (it is enabled by default)
-nb do not add the byteman jar to the bootstrap classpath (it is
added by default)
-nb do not inject into java.lang classes (it is enabled by default)
– optional separator to distinguish trailing arguments
javaargs trailing arguments to be supplied to the java command
Environment:
If BYTEMAN_HOME is set the script expects the byteman jar to be located in
BYTEMAN_HOME/lib/byteman.jar.
If BYTEMAN_HOME is not set then it assumes the script is being run from BYTEMAN_HOME/bin and sets BYTEMAN_HOME accordingly.
If BYTEMAN_JAVA_ARGS is set then it is assumed to contain extra arguments to the java command which are to be inserted before the -javaagent argument.
Behaviour:
The script constructs a -javaagent argument to pass to the java command found in the current execution PATH. The -javaagent argument is prefixed with any arguments provided via BYTEMAN_JAVA_ARGS and suffixed with the values supplied via javaargs. The resulting command is run using an exec command.