Skip to content

Writing Front-Ends

JEB front-end are also referred to as "JEB clients" (or "JEB third-party clients", to contrast with the "official UI desktop client").

JEB back-end API makes writing new clients (aka, front-ends) an easy task. A client can be:

  • An automated client (for testing, for an automation pipeline)
  • A command-line client
  • A graphical front-end (e.g., the official UI desktop client)
  • ...

Note

Not all JEB licenses allow the creation of third-party clients. Verify this by checking your license information in the About dialog box. It should show any-client. Typically, JEB Pro licenses allow the execution of third-party clients.

High-level Instructions#

Use the provided source code template (see below) as a base for your client. The basic steps any client should take are the following:

Refer to the our simplified architecture diagrams to better visualize how those components are connected to one another.

Source Template#

Full source code: Command-line client skeleton on GitHub

import java.io.File;

import com.pnfsoftware.jeb.core.JebCoreService;
import com.pnfsoftware.jeb.core.units.IUnit;
import com.pnfsoftware.jeb.util.base.Env;
import com.pnfsoftware.jeb.util.io.IO;
import com.pnfsoftware.jeb.util.logging.GlobalLog;
import com.pnfsoftware.jeb.util.logging.ILogger;

/**
 * Skeleton file for a custom JEB client. Requires JEB Pro version 5.37 or above.
 * <p>
 * This client assumes that an installation of JEB, with a valid license key, is pointed to by a
 * {@code JEB_HOME} environment variable.
 *
 */
public class JebCustomClientSample {
    static final ILogger logger = GlobalLog.getLogger(JebCustomClientSample.class);
    static {
        GlobalLog.addDestinationStream(System.out);
    }

    // provide a folder with files as the command-line argument
    public static void main(String[] args) throws Exception {
        if(args.length == 0) {
            throw new RuntimeException("Provide a directory for scanning as the first command-line argument");
        }

        var jebHome = Env.get("JEB_HOME");
        if(jebHome == null) {
            throw new RuntimeException("Set the JEB_HOME environment variable to point to your JEB folder");
        }

        // instantiate the JEB core service
        var jeb = JebCoreService.getInstance(new File(jebHome));

        // create an engines context (a container of JEB projects)
        var engctx = jeb.createEnginesContext();

        // scan some files
        var files = IO.listFiles(args[0]);
        int i = 0;
        for(var file: files) {
            i++;
            logger.info("Processing file %d/%d : %s ...", i, files.size(), file.getName());

            // create or load a project (artifact container)
            var prj = engctx.createProject("ProjectTest" + i);

            // process the artifact, get units
            var art = prj.processArtifact(file);

            // proceed with the units
            var units = art.getUnits();

            // work with the units
            for(IUnit unit: units) {
                logger.info("Unit: %s", unit);
                //
                // ... do some work
                //
            }

            engctx.unloadProject(prj.getKey());
        }

        // close our engines context
        jeb.closeEnginesContext(engctx);

        // close JEB
        jeb.close();
    }
}