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

From Info216
m (Sinoa moved page Lab-Eclipse-Java-Jena to Lab 1: Getting started with Eclipse, Java and Jena without leaving a redirect)
Line 17: Line 17:
  
 
==Tasks==
 
==Tasks==
Download and install a Java Runtime Environment (JRE) if you do not have it, for example Java 8 update 66:
+
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/
 
https://www.java.com/en/download/
  
Download and unpack Java SE Development Kit (JDK) 8 (e.g. update 66):
+
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.
 
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.
 
(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".
 
On my Windows computer, I put everything under a folder called "C:\Programs". On Linux, I use the folder "/opt".
  
Download and unpack Eclipse Mars.1 IDE for Java Developers:
+
Download and unpack Eclipse Neon.2 IDE for Java Developers: go to
http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/marsr
+
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.
 
Start Eclipse by going to the directory where you installed it and doubleclick the "eclipse" program.
Line 34: Line 35:
 
Help -> Preferences -> Java -> Installed JREs -> Add...
 
Help -> Preferences -> Java -> Installed JREs -> Add...
  
Download and unpack Jena 3.0.1, both the binary and the source distribution:
+
Download and unpack Jena 3.1.1, both the binary and the source distribution:
 
https://jena.apache.org/download/
 
https://jena.apache.org/download/
  
 
(While you are at it, you can just download and unpack Apache Jena Fuseki too.
 
(While you are at it, you can just download and unpack Apache Jena Fuseki too.
Take both the 2.3.1 and 1.3.1 distributions for now.)
+
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).
 
Start Eclipse again and create an Eclipse project for Java (File -> New -> Java Project).
 
Copy or link the Jena JAR-files into the project:
 
Copy or link the Jena JAR-files into the project:
.../apache-jena-3.0.1/lib/*.jar .
+
.../apache-jena-3.1.1/lib/*.jar .
  
 
Write a Java program that creates a single triple and writes it out.
 
Write a Java program that creates a single triple and writes it out.

Revision as of 17:23, 11 January 2017

Lab 1: Getting started with Eclipse, Java and Jena

Topics

Installation of and introduction to Eclipse and Jena.

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