Sahi Documentation

Adding jars to Sahi's classpath

While interacting with databases or while calling custom java code from Sahi scripts, the necessary jars need to be added to Sahi's classpath.
info From Sahi Pro V5.1.0.0 onwards, we need to only add the jars to sahi_pro/userdata/extlib directory. All jars in sahi_pro/userdata/extlib are automatically added to Sahi Pro's classpath.

From command-line

If Sahi is started from the desktop shortcut or via commandline using start_sahi.bat or start_dashboard.bat, just copy the needed jars to sahi_pro/userdata/extlib.
warning DO NOT use subfolders. Jars should be copied directly into sahi_pro/userdata/extlib folder.

From ant

If you are using ant, jars need to be copied in sahi_pro/userdata/extlib and additionally, we need to add sahi_pro/userdata/extlib as a path element to the classpath:
<target name="startsahi" description="starts proxy">
        <java classname="net.sf.sahi.Proxy" fork="true">
          <classpath>
            <path path="classes"/>
            <pathelement location="extlib/rhino/js.jar"/>
            <pathelement location="extlib/apacheclient/commons-codec-1.10.jar"/>
            .. and other Sahi jars ...
            <pathelement location="userdata/extlib/**"/>
            <pathelement location="C:/mypath/custom.jar"/>
          </classpath>
    <arg value="." id="basePath"/>
    <arg value="./userdata/" id="userdataPath"/>
  </java>
</target>
warning DO NOT use subfolders. Jars should be copied directly into sahi_pro/userdata/extlib folder.
Make sure to change the pathelement locations properly. (Relative to where you are running the target from.)