Difference between revisions of "Lab: Getting started with Eclipse, Java and Jena"

From Info216
Line 3: Line 3:
 
==Topics==  
 
==Topics==  
 
Installation of and introduction to Eclipse and Jena.
 
Installation of and introduction to Eclipse and Jena.
 +
 +
==Preparations==
 +
This is a good, but loong, tutorial about Eclipse: [http://www.vogella.com/tutorials/Eclipse/article.html Eclipse IDE - Tutorial by Vogella.com]. A good start is to look at sections 1 and 5-7.
 +
 +
The introductions to Jena are the same as in lecture one!
  
 
==Relevant Jena classes/interfaces (and methods)==
 
==Relevant Jena classes/interfaces (and methods)==

Revision as of 15:02, 12 January 2017

Lab 1: Getting started with Eclipse, Java and Jena

Topics

Installation of and introduction to Eclipse and Jena.

Preparations

This is a good, but loong, tutorial about Eclipse: Eclipse IDE - Tutorial by Vogella.com. A good start is to look at sections 1 and 5-7.

The introductions to Jena are the same as in lecture one!

Relevant Jena classes/interfaces (and methods)

  • ModelFactory (createDefaultModel),
  • Model (createResource, createProperty, write)
  • Resource (addLiteral)
  • Property

(The JavaDoc is here: https://jena.apache.org/documentation/javadoc/jena/ . 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.)

Tasks

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". On Linux, I use the folder "/opt".

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.)

Start Eclipse by going 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/

(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.)

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" buttom 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.

Honour tasks

(For some of the later labs we will also suggest more advanced tasks for those of you who are more experienced.)