rdf using apache jena on net beans

£可爱£侵袭症+ 提交于 2019-12-08 11:40:38

问题


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:

  1. File -> New Project. Choose Maven then Java Application.
  2. Pick project name, location, etc., then Finish.
  3. Netbeans will create a new maven project and open it.
  4. Right click on Dependencies, choose Add Dependency....
  5. Use org.apache.jena as the Group ID, jena-core (or jena-arq if you want SPARQL) as the Artifact ID, and 2.10.1 as the Version.
  6. 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 on Dependencies again and choose Download Declared Dependencies to ensure jena is ready for use.
  7. Under Source Packages you'll find App.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!