Preliminaries#
KnowWE is commonly used to develop and maintain a knowledge base. Later, the built knowledge base is deployed and used in the context of a larger application. For this reason, it becomes important to load knowledge bases and run problem-solving sessions without the KnowWE context.
The following notes explain how to develop your own Eclipse project with all plugins required to run a d3web application.
Create your Eclipse Project#
- Simply start a new Java project and create (if not already done) a new folder "lib".
- Copy all d3web jars (including necessary foreign jars) into the lib folder (these jars can be easily accessed from d3web/bin/lib in the current KnowWE Distribution) : http://sourceforge.net/projects/d3web
- Java Project Properties: Project->Build Path->Libraries: Add all jars as Jar libraries to the project
Some Demo Code#
In your own code, you are first required to load the plugins for the knowledge base persistence etc.; this is accomplished by the JPFPluginManager.
private void demo() throws IOException { // Initializing the plugins for the persistence // retrieve all relevant plugins in folder "lib" File[] files = getAllJPFPlugins("lib"); JPFPluginManager.init(files); // Alternatively: just pass the folder and ignore warnings // when file not a jpf plugin // JPFPluginManager.init("lib"); // Loading the knowledge base and do some retrieval of solutions and questions PersistenceManager persistenceManager = PersistenceManager.getInstance(); String knowledgeFilename = "/temp/d.jar"; // Load knowledge base KnowledgeBase knowledgeBase = persistenceManager.load(new File(knowledgeFilename )); List<Solution> solutions = knowledge.getManager().getSolutions(); System.out.println(solutions); List<Question> questions = knowledge.getManager().getQuestions(); System.out.println(questions); } private File[] getAllJPFPlugins(String libFolder) { List<File> fileList = new ArrayList<File>(); for (File file : new File(libFolder).listFiles()) { if (file.getName().contains("-jpf-plugin")) fileList.add(file); } return fileList.toArray(new File[fileList.size()]); }