This code is slightly modified from javapapers.com/core-java/java-instrumentation/ which is a very good example of how to start using Javassist.
Clearly, since this is a Javassist tutorial, you need to have the Java JDK installed and the Javassist library somewhere on your computer.
- In Eclipse, right-click the "example.jardesc" file and click "Create Jar"
- From command line:
- Navigate to the "bin" directory
- Type:
jar cvfm example.jar ..\META-INF\MANIFEST.MF .
From the command line in the "bin" directory, type:
java -cp .;..\..\lib\javassist.jar -javaagent:.\example.jar javassistExample.TestInstrumentation
Note: Replace ..\..\lib\javassist.jar
with the path to Javassist on your computer.