The problem I initially told was a part of the entire idea.
Here is what I require.
I want to write a java program that should look through all the RDF files
in a given folder. The java program is given a string as input.
The program has to look for the value of <RDF.subject> element in each of
the RDF file to see if the value matches with the given input string. If
there is a match, then the value of the <RDF.object> should be obtained and
stored in a string array.
The following is my java code.
import java.io.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.util.FileManager;
public class RdRDF extends Object
{
public static void main(String args[])
{
try
{
// create an empty model
Model model = ModelFactory.createDefaultModel();
//look at all the files in the folder
String path = "C:\\Program Files\\Apache Software Foundation\\Tomcat
6.0\\webapps\\MyFiles\\WEB-INF\\classes\\";
String files;
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
{
if (listOfFiles[i].isFile())
{
files = listOfFiles[i].getName();
if (files.endsWith(".rdf"))
{
model.read(files, null);
//read the domain
System.out.println(files + "\t");
Resource vcard = model.getResource("http://www.wordpress.com/blogs/" +
files);
String domain = vcard.getProperty(RDF.subject).getString();
System.out.println(domain + "\n");
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
When I run this code,
I get the following error.
C:\Program Files\Apache Software Foundation\Tomcat
6.0\webapps\MyFiles\WEB-INF\c
lasses>java RdRDF
Exception in thread "main" java.lang.NoClassDefFoundError:
com/hp/hpl/jena/rdf/m
odel/ModelFactory
at RdRDF.main(RdRDF.java:18)
Caused by: java.lang.ClassNotFoundException:
com.hp.hpl.jena.rdf.model.ModelFact
ory
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)
... 1 more
C:\Program Files\Apache Software Foundation\Tomcat
6.0\webapps\MyFiles\WEB-INF\c
lasses>
Please tell me what mistake I have done.