问题
I want to create a simple RDF graph and then try simple querying using SPARQL. Since I'm familiar with java and net beans, I want to use Apache Jena on NetBeans. I downloaded the related files from http://www.apache.org/dist/jena/ .
What should I do next to write RDF codes on net beans? i.e Should I install something or add lib files/jar files somewhere?
回答1:
(Too long for a comment on Ian's reply)
Maven is easy on netbeans, and a good way to get started with everything you need (as Ian says). Here's a quick guide to start a jena project:
File -> New Project
. ChooseMaven
thenJava Application
.- Pick project name, location, etc., then
Finish
. - Netbeans will create a new maven project and open it.
- Right click on
Dependencies
, chooseAdd Dependency...
. - Use
org.apache.jena
as the Group ID,jena-core
(orjena-arq
if you want SPARQL) as the Artifact ID, and2.10.1
as the Version. - Open the
Dependencies
folder. It ought to have a number jars present -- these are jena and its required jars. You might need to right-click onDependencies
again and chooseDownload Declared Dependencies
to ensure jena is ready for use. - Under
Source Packages
you'll findApp.java
. Try some of the simple jena api tutorials and try running them.
回答2:
You need to put the .jar
files from the Jena distribution where Netbeans will find them. I don't know Netbeans, but in Eclipse I might have a lib directory in my project top-level directory, and then set the Eclipse's project classpath to include each of those .jar
files. Netbeans I'm sure has something similar.
Actually what I do in Eclipse is not use downloaded jars at all, but I would use Maven to manage the dependencies for me. So I would create a pom.xml
file in my project folder that stated that, among other things, my project depends on Jena, and then Maven takes care of downloading the dependencies for me. Eclipse and Maven work well together; I'd hope the same would be true of Netbeans. Setting up Maven to use Jena is described on the Jena site. However, learning Maven can be a bit of a steep curve, so if you're not ready to take that on just yet then downloading the .jar
files to a project lib directory is the way to go.
来源:https://stackoverflow.com/questions/16728487/rdf-using-apache-jena-on-net-beans