找不到 QueryFactory 的符号 - jena API

发布于 2024-10-27 01:25:12 字数 1738 浏览 1 评论 0原文

import java.io.*;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.db.*;
import com.hp.hpl.jena.db.impl.*;
import com.hp.hpl.jena.graph.compose.*;
import com.hp.hpl.jena.graph.query.*;
import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.ModelMaker.*;
import com.hp.hpl.jena.mem.*;
import com.hp.hpl.jena.mem.faster.*;

class Firstsparql{

    public static void main(String[] args){
        // Open the bloggers RDF graph from the filesystem
        InputStream in = new FileInputStream(new File("foaf.rdf"));

        // Create an empty in-memory model and populate it from the graph
        Model model = ModelFactory.createMemModelMaker().createModel();
        model.read(in,null); // null base URI, since model URIs are absolute
        in.close();

        // Create a new query
        String queryString =
        "PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
        "SELECT ?url " +
        "WHERE {" +
        "      ?contributor foaf:name \"Jon Foobar\" . " +
        "      ?contributor foaf:weblog ?url . " +
        "      }";

        Query query = QueryFactory.create(queryString);

        // Execute the query and obtain results
        QueryExecution qe = QueryExecutionFactory.create(query, model);
        ResultSet results = qe.execSelect();

        // Output query results
        ResultSetFormatter.out(System.out, results, query);

        // Important – free up resources used running the query
        qe.close();
        }
}

您好,我已将 jena.jar 文件包含在我的类路径中,但仍然有一些变量和方法无法识别。我希望它们没有在 jena api 中定义..还有我需要包含的其他 api..请告诉我..知道。谢谢。

import java.io.*;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.db.*;
import com.hp.hpl.jena.db.impl.*;
import com.hp.hpl.jena.graph.compose.*;
import com.hp.hpl.jena.graph.query.*;
import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.ModelMaker.*;
import com.hp.hpl.jena.mem.*;
import com.hp.hpl.jena.mem.faster.*;

class Firstsparql{

    public static void main(String[] args){
        // Open the bloggers RDF graph from the filesystem
        InputStream in = new FileInputStream(new File("foaf.rdf"));

        // Create an empty in-memory model and populate it from the graph
        Model model = ModelFactory.createMemModelMaker().createModel();
        model.read(in,null); // null base URI, since model URIs are absolute
        in.close();

        // Create a new query
        String queryString =
        "PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
        "SELECT ?url " +
        "WHERE {" +
        "      ?contributor foaf:name \"Jon Foobar\" . " +
        "      ?contributor foaf:weblog ?url . " +
        "      }";

        Query query = QueryFactory.create(queryString);

        // Execute the query and obtain results
        QueryExecution qe = QueryExecutionFactory.create(query, model);
        ResultSet results = qe.execSelect();

        // Output query results
        ResultSetFormatter.out(System.out, results, query);

        // Important – free up resources used running the query
        qe.close();
        }
}

Hi, i have included jena.jar file in my classpath but still some of variables and methods are not recognised. ihope they are not defined in jena api..is there any other api i need to include.pls..let me..know. thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒浓于脸红 2024-11-03 01:25:12

您的 CLASSPATH 需要包含 Jena lib 目录中的所有 .jar 文件,而不仅仅是 jena.jar

Your CLASSPATH needs to include all of the .jar files in the Jena lib directory, not just jena.jar.

素衣风尘叹 2024-11-03 01:25:12

除了上面的建议之外,您还可以在 https://jena.apache.org/documentation

特别是,Jena 用于处理 SPARQL 查询的部分称为 ARQ。 ARQ.jar涉及QueryFactory。

Apart from advise above, you can read about jena's architecture on https://jena.apache.org/documentation

Particularly, Jena's part for process SPARQL query called ARQ. ARQ.jar involves QueryFactory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文