How to add a .jar library to a module project

External .jar libraries can be added to module projects classpath during development phases. The sections below describe how to update the module project.

Adding the .jar library to the module project classpath

  • Include the .jar file inside the module project,
  • Right-Click on the .jar file to add it to the build path:

Adding the .jar library to the compilation classpath

The .jar library also needs to be added to the compilation classpath when building the module with the Build Module command:

  • Create a module.ant file at the root of the module project,

  • Add the following code inside module.ant:

    <project name="com.microej;helloworld" xmlns:ea="antlib:org.apache.easyant">
    
        <ea:plugin module="abstract-compile" revision="0.9" />
    	
        <target name="add-external-lib:augment-classpath" extensionOf="abstract-compile:compile-ready">
        	<ea:path pathid="compile.main.classpath" overwrite="append">
    	    <fileset dir="${basedir}/external_library" includes="mylib-2.0.0.jar" />
            </ea:path>
        </target>
    
    </project>
    
  • Launching the Build Module command will trigger the script execution.

If you want to know more about module projects and MMM, check MicroEJ Module Manager — MicroEJ Documentation.

Alex for MicroEJ

1 Like