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.