Show Table of Contents
2.2. Create the Knowledge Base
A knowledge base needs to contain all of the process definitions, or references to the process definitions, that the session might need to execute.
Use a knowledge builder to load the processes from the required resources (for example, the classpath or file system) and then create a new knowledge base from the knowledge builder. The following code snippet creates a knowledge base consisting of one process definition using a resource from the classpath.
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("MyProcess.bpmn"), ResourceType.BPMN2);
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
The
ResourceFactory has similar methods to load files from file system, URL, InputStream, and Reader.
A knowledge base can be shared across sessions and is usually created once at the start of the application. Knowledge bases can be changed dynamically, allowing processes to be added or removed at runtime.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.