title: how to load drl file from file system in drools 6.3.0
body: <p>Hi I am trying to load drl file from file system in drools 6.3.0.
  I got the code from drools project. Code that is used to load drl file is as follows.</p>
  
  <pre><code>package org.drools.examples.banking;
  
  import org.kie.internal.KnowledgeBase;
  import org.kie.internal.KnowledgeBaseFactory;
  import org.kie.internal.builder.KnowledgeBuilder;
  import org.kie.internal.builder.KnowledgeBuilderFactory;
  import org.kie.internal.definition.KnowledgePackage;
  import org.kie.internal.io.ResourceFactory;
  import org.kie.internal.runtime.StatefulKnowledgeSession;
  import org.kie.api.io.ResourceType;
  
  import java.util.Collection;
  
  public class RuleRunner {
  
      public RuleRunner() {
      }
  
      public void runRules(String[] rules,
                           Object[] facts) {
  
          KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
  
          for ( int i = 0; i &lt; rules.length; i++ ) {
              String ruleFile = rules[i];
              System.out.println( "Loading file: " + ruleFile );
              kbuilder.add( ResourceFactory.newClassPathResource( ruleFile,
                                                                          RuleRunner.class ),
                                    ResourceType.DRL );
          }
  
          Collection&lt;KnowledgePackage&gt; pkgs = kbuilder.getKnowledgePackages();
          kbase.addKnowledgePackages( pkgs );
          /*ResourceFactory.getResourceChangeNotifierService().start();
          ResourceFactory.getResourceChangeScannerService().start();
          */
          StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
  
          for ( int i = 0; i &lt; facts.length; i++ ) {
              Object fact = facts[i];
              System.out.println( "Inserting fact: " + fact );
              ksession.insert( fact );
          }
  
          ksession.fireAllRules();
      }
  }
  </code></pre>
  
  <p>Here KnowledgeBase is deprecated. Is there any alternative for  KnowledgeBase. If any alternative exist kindly provide me sample code for that. I don't want to copy drl file in resources folder of the application. Any help is appreciated. At the end i did it as follows:</p>
  
  <pre><code>KieServices kieServices = KieServices.Factory.get();
          KieFileSystem kfs = kieServices.newKieFileSystem();
          kfs.write(ResourceFactory.newFileResource(new File("C:/Users/ab/Desktop/fly.drl")));
          KieBuilder kieBuilder = kieServices.newKieBuilder(kfs).buildAll();
          KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId());
          KieSessionConfiguration conf=  SessionConfiguration.getDefaultInstance();
          KieSession ksession = kieContainer.newKieSession(conf);
          if (kieBuilder.getResults().hasMessages(Level.ERROR)) {
              List&lt;Message&gt; errors = kieBuilder.getResults().getMessages(Level.ERROR);
              StringBuilder sb = new StringBuilder("Errors:");
              for (Message msg : errors) {
                  sb.append("\n  " + msg);
              }
              throw new Exception(sb.toString());
          }
  
          System.out.println("KieServices built: ");
  </code></pre>