Difference between revisions of "Lab: Getting started with Eclipse, Java and Jena"
|Line 60:||Line 60:|
directory as your Java-files.
directory as your Java-files.
some of the
Revision as of 15:26, 12 January 2017
Lab 1: Getting started with Eclipse, Java and Jena
Installation of and introduction to Eclipse and Jena.
For Eclipse, Vogella.com has a good, but loong, tutorial: Eclipse IDE - Tutorial by Vogella.com. A good start is to look at sections 1 and 5-7.
For Jena, you can look at these pages from lecture 1, in particular:
Relevant Jena classes/interfaces (and methods)
- ModelFactory (createDefaultModel),
- Model (createResource, createProperty, write)
- Resource (addLiteral)
(For example, click "All classes" in the upper-left frame. Then you can focus the lower-left frame with a browser click, and use browser search (often Ctrl-F) to find the class or interface you want.)
Download and install a Java Runtime Environment (JRE) if you do not have it, for example Java 8 update 111: https://www.java.com/en/download/
Download and unpack Java SE Development Kit (JDK) 8 (e.g. update 111/112): http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html#javasejdk. (It is smart to download and unpack all the files into subfolders of the same folder, so you know where you have them. On my Windows computer, I put everything under a folder called "C:\Programs\Java". On Linux, I use the folder "/opt/Java".)
Download and unpack Eclipse Neon.2 IDE for Java Developers: go to https://eclipse.org/downloads/ and Get Eclipse Neon for your computer and operating system. (There are many versions of Eclipse. You need one for "Java Developers", but not anything with "Enterprise" or "EE".)
Start Eclipse from the start menu (on Linux, go to the directory where you installed it and doubleclick the "eclipse" program). If you want to, you can make a shortcut to the "eclipse" program from your desktop or program bar.
Tell Eclipse that you are going to use the JDK 8 you just downloaded. Help -> Preferences -> Java -> Installed JREs -> Add...
Download and unpack Jena 3.1.1, both the binary and the source distribution: https://jena.apache.org/download/ . (I use folders called "C:\Programs\Jena" and "/opt/Jena" for this.)
While you are at it, you can just download and unpack Apache Jena Fuseki too. Take both the 2.4.1 and 1.4.1 distributions for now. We will need at least one of them later.
Start Eclipse again and create an Eclipse project for Java (File -> New -> Java Project). Copy or link the Jena JAR-files into the project: .../apache-jena-3.1.1/lib/*.jar .
Write a Java program that creates a single triple and writes it out. Use the Classes/interfaces and methods listed above. The simplest way to run the program is using the green "play" button in the top toolbar.
Go to the File Storage here in the portal and download the file log4j.properties from the Misc folder. You can get rid of the "log4j warnings" by copying the log4j.properties file into exactly the same directory as your Java-files.
If you have more time...
If you have more time you can continue extending your graph with some of the stuff from lab 2: "Cade Tracy lives in 1516 Henry Street, Berkely, California 94709, USA. He has a B.Sc. in biology from the University of California, Berkeley from 2011. His interests include birds, ecology, the environment, photography and travelling. He has visited Canada and France." Try to use as many different methods as possible to create the triples.