Skip to main content
Skip table of contents

Add custom Java class to a back end project

Custom Java classes can be added to a project as JAR files in the <project>/libs or <workspace>/libs folders.

You can already use the native Java 1.8 classes in a SequenceJS step.

JS
var md5 = use("org.apache.commons.codec.digest.DigestUtils.md5hex");
log.message("md5: " + md5("hello world"));

The use can be used to load a native Java function and speedup the loading of this function for next calls.

The idea is to share memory between multiple request, cross sessions.
This can be useful in some case, to keep global object or function.

CODE
var myfun = project.get("myfun");
if (myfun == null) {
  myfun = function (a, b) {
    return a + b;
  }
  project.set("myfun", myfun);
}

myfun(1, 2);

The server object works like project but global to the server.

See more details here https://doc.convertigo.com/documentation/latest/reference-manual/convertigo-mbaas-server/javascript-objects-apis/#methods-detailed-list-1

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.