简体   繁体   English

在Java中使用Freebase API

[英]Using Freebase API in Java

I am developing a GWT application to get the query results from the Freebase. 我正在开发一个GWT应用程序来从Freebase获取查询结果。 This is the code of my EntryPoint class. 这是我的EntryPoint类的代码。

package com.google.tracker.client;

import com.freebase.api.Freebase;
import com.freebase.json.JSON;
import com.google.gwt.core.client.EntryPoint;

public class Tracker implements EntryPoint{

    public void onModuleLoad() {
        Freebase freebase = Freebase.getFreebase();
        String query_str = "{" +
                "'id':   null," +
                "'type': '/film/film'," +
                "'name': 'Blade Runner'," +
                "'directed_by': [{" +
                "'id':   null," +
                "'name': null" +
                "}]" +
                "}​".replace('\'', '"');

        JSON query = new JSON(query_str);
        JSON result = freebase.mqlread(query);
        @SuppressWarnings("unused")
        String director = result.get("result").get("directed_by").get(0).get("name").string();
    }
}

I am getting following errors : 我收到以下错误:

[ERROR] Line 10: No source code is available for type com.freebase.api.Freebase; did you forget to inherit a required module?
[ERROR] Line 21: No source code is available for type com.freebase.json.JSON; did you forget to inherit a required module?

What could be the possible reasons for these? 这些可能是什么原因?

Freebase's API package is not a GWT module and as such can't be translated to Javascript. Freebase的API包不是GWT模块,因此无法转换为Javascript。 That's why there's "No source code available". 这就是为什么“没有可用的源代码”的原因。 You need to make the call to Freebase from the server and send the results down to the client. 您需要从服务器调用Freebase并将结果发送给客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM