0

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;

I donwloaded Jena at http://www.apache.org/dist/incubator/jena/apache-jena-2.7.0-incubating/. Once downloaded I unzipped it and leave it as it is.

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.

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.

To make it simple to use in the command line I moved my file "MyKnowledgeBase.rdf" in the lib folder.

I tried from the lib folder

java jena.schemagen -i "myKnowledgeBase.rdf"

and get this

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.

So I tried to set the classpath :

C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating\lib>
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;

But I have still the same error. I also tried with

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

when I do

echo %CLASSPATH% 

I get what I entered

I tried to use set CLASSPATH with the absolute path for each jar and it doesn't work too.

So now I don't know what to do.

In Jena I found the schemagen.class in the package "jena" from the jena-core-2.7.0-incubating.jar (with netbeans)

With explorer I didn't find the class file.

I already run several projects in the command line doing java -jar so java and the command line is ok

Thank you for your help

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 !

"Unrecognized option" and "Could not create the java virtual machine"

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 :

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
SabineA
  • 81
  • 1
  • 1
  • 4
  • This question is more related to "how to setup Java CLASSPATH" than Jena itself. Jena is just a set of jars you need to have in your Java CLASSPATH (as with many others Java projects). – castagna Jun 21 '12 at 19:27
  • True but I was also confused by Jena zip file and where exactly is the class file (if it help executing the program) or as the answer below if there is a executable file. – SabineA Jun 21 '12 at 19:46

2 Answers2

1

In all recent releases, including Jena 2.7.0, Linux shell and Windows batch scripts are provided for all of the Jena command line tools. These scripts set the CLASSPATH appropriately. Since you seem to be using Windows, you should use bat\schemagen.bat.

Ian Dickinson
  • 12,875
  • 11
  • 40
  • 67
0

I had the same problem.I 'm using Jena 3.10 if anyone having the same problem , the solution for this is using schemagen bat file that located in the bat folder. I used this command line for generating the vocabulary

C:\Jena\apache-jena-3.10.0\bat\schemagen.bat -i "FileName"

Ak_IN
  • 1
  • 2