As Andy said, in the example code of Dave GoodStudent is an object of type OntClass, not a String object. The problem is mostly your code quality, I kindly suggest you to use proper Jena objects if possible to avoid those problems...
On 21.09.2016 12:46, javed khan wrote: > Hello Andy, shouldn't there be the class name to which we assign new > individuals.? > inf.listResourcesWithProperty(RDF.type, > "GoodStudent") > > Dave run this code and it works for him, but I do not know why, it does not > work for me. > > On Wed, Sep 21, 2016 at 2:18 AM, Andy Seaborne <a...@apache.org> wrote: > >> The rules have some syntax problems: >> >> "( ?x http://www.semanticweb.org#GPA ?score + )" >> >> as mentioned earlier in the thread then >> >> "greaterThan(?score, userscore) " >> >> but userscore is a java variable. >> >> Also >> >> inf.listResourcesWithProperty(RDF.type, >> "GoodStudent") >> >> uses a string not a URI so if not going to find anything. >> >> Andy >> >> >> On 21/09/16 09:21, Lorenz B. wrote: >> >>> Are you sure that this code compiles? >>> >>> Property prop= model.getProperty(ns,"GPA"); >>> ns is a String in your code, the method expects a Resource object is >>> first argument. You totally use the wrong method here, as it returns a >>> Statement. >>> >>> Model::createProperty(String nameSpace, String localName) >>> >>> would be the method to call, or even better as you use an OntModel >>> >>> OntModel::getDatatypeProperty( String uri ) >>> >>> >>>