title: Execute Schemagen (Jena) from the command line / classpath setting
body: <p>I am learning the Jena API and I want to use Schemagen to create the classes that look like in the package com.hp.hpl.jena.vocabulary for my own vocabulary;</p>
  
  <p>I donwloaded Jena at <a href="http://www.apache.org/dist/incubator/jena/apache-jena-2.7.0-incubating/" rel="nofollow">http://www.apache.org/dist/incubator/jena/apache-jena-2.7.0-incubating/</a>. Once downloaded I unzipped it and leave it as it is. </p>
  
  <p>C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating 
  is the folder where there is the bat folder, the bin folder, the javadoc-arq folder etc.</p>
  
  <p>I tested Jena in one of my project using all the libraries in C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating\lib with a relative link, and it works.</p>
  
  <p>To make it simple to use in the command line I moved my file "MyKnowledgeBase.rdf" in the lib folder.</p>
  
  <p>I tried from the lib folder</p>
  
  <pre><code>java jena.schemagen -i "myKnowledgeBase.rdf"
  </code></pre>
  
  <p>and get this</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: jena/schemagen
  Caused by: java.lang.ClassNotFoundException: jena.schemagen
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
  Could not find the main class: jena.schemagen.  Program will exit.
  </code></pre>
  
  <p>So I tried to set the classpath :</p>
  
  <pre><code>C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating\lib&gt;
  set CLASSPATH=commons-codec-1.5.jar;httpclient-4.1.2.jar;httpcore-4.1.3.jar;icu4j3.4.4.jar;jena.arq-2.9.0-incubating.jar;jena.core-2.7.0-incubating.jar;jena.iri0.9.0-incubating.jar;log4j-1.2.16.jar;slf4j-api-1.6.4.jar;slf4j-log4j12-1.6.4.jar;xercesImpl-2.10.0.jar; xml-apis-1.4.01.jar;
  </code></pre>
  
  <p>But I have still the same error. I also tried with</p>
  
  <pre><code>java -cp commons-codec-1.5.jar;httpclient-4.1.2.jar;httpcore-4.1.3.jar;icu4j3.4.4.jar;jena.arq-2.9.0-incubating.jar;jena.core-2.7.0-incubating.jar;jena.iri0.9.0-incubating.jar;log4j-1.2.16.jar;slf4j-api-1.6.4.jar;slf4j-log4j12-1.6.4.jar;xercesImpl-2.10.0.jar; xml-apis-1.4.01.jar; jena.schemagen -i myKnowledgeBase.rdf
  </code></pre>
  
  <p>when I do</p>
  
  <pre><code>echo %CLASSPATH% 
  </code></pre>
  
  <p>I get what I entered</p>
  
  <p>I tried to use set CLASSPATH with the absolute path for each jar and it doesn't work too.</p>
  
  <p>So now I don't know what to do.</p>
  
  <p>In Jena I found the schemagen.class in the package "jena" from the jena-core-2.7.0-incubating.jar (with netbeans)</p>
  
  <p>With explorer I didn't find the class file.</p>
  
  <p>I already run several projects in the command line doing java -jar so java and the command line is ok</p>
  
  <p>Thank you for your help</p>
  
  <p>Edit :
  I removed the space between the argument -classpath and %CLASSPATH% and I get something different \o/ still doesn't work but it's in progress !</p>
  
  <p>"Unrecognized option" and "Could not create the java virtual machine"</p>
  
  <p>Edit2 : 
  As I was unable to solve this I created a new project with netbeans. I created a copy of schemagen class, put it as the main class, include all the jar as libraries.
  and then : </p>
  
  <pre><code>java -jar "C:\Users\moi\NetBeansProjects\MyJena\dist\MyJena.jar" -i "myKnowledgeBase.rdf" -o "C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating\lib" --ontology
  </code></pre>