简体   繁体   中英

Using Freebase API in Java

I am developing a GWT application to get the query results from the Freebase. This is the code of my EntryPoint class.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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