For your java projects to compile, you must have the c4j.jar library in your classpath. We will discuss the best way how to add the library below.
In order to enable contract verification during the runtime of your application, you need to supply a -javaagent VM argument and enable assertions. You could do this in the command-line like:
java -cp <your_classpath> -javaagent:$ECLIPSE_HOME/plugins/net.sourceforge.c4jplugin.runtime/c4j.jar -ea <your_main_class>
where $ECLIPSE_HOME stands for your Eclipse installation path, assuming that you installed the net.sourceforge.c4jplugin.runtime plug-in in the standard Eclipse plug-ins folder. But this is not the preferred way, since Eclipse uses run configurations to run your applications.
Note: The plug-in net.sourceforge.c4jplugin can automatically perform the following steps for you. See the C4J Plug-in User Guide for more information.
To add c4j.jar to your build path and enable C4J for a specific run configuration of your java project, follow these two steps:
Because the c4j.jar library is contained in the plugin net.sourceforge.c4jplugin.runtime, you can add the plug-in to the list of required plug-ins in your MANIFEST.MF file. Then you need to add the VM arguments as above: