Ariel Ariel - 3 months ago 10
Java Question

Why do I have these warnings with Jena 2.11.0?

I am using Eclipse and Java. I've setup the jena library and done my first RDF statement using this library, but I get a warning and I don't know exactly what it means.
This is the code:

import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;

public class Main {

public static void main(String[] args) {
Model m = ModelFactory.createDefaultModel();
String NS = "http://www.example.org/rdf/";
Resource r = m.createResource(NS + "r");
Property p = m.createProperty(NS + "p");
r.addProperty(p, "hello world", XSDDatatype.XSDstring);
m.write(System.out, "Turtle");
}

}


And this is the output:

log4j:WARN No appenders could be found for logger (org.apache.jena.riot.stream.JenaIOEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
<http://www.example.org/rdf/r>
<http://www.example.org/rdf/p> "hello world"^^<http://www.w3.org/2001/XMLSchema#string> .


So the code does compile and work but I don't know what to do about this warning.
How can I get rid of it?

Answer

I finally managed to solve the problem. Thanks to AndyS for the solution.

Copy the "jena-log4j.properties" file inside the folder of the application and add the following line of code at the start of the main:

Log.setLog4j("jena-log4j.properties");