Why do I get "Native methods do not specify a body" when I try to use JSNI?

701 views
Skip to first unread message

Shedokan

unread,
Jun 20, 2010, 11:55:51 AM6/20/10
to Google Web Toolkit
I have this Class:

package com.testproject.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Test implements EntryPoint {

/**
* This is the entry point method. Initialize you GWT module here.
*/
public void onModuleLoad() {
// Writes Hello World to the module log window.
GWT.log("Hello World!", null);
GWT.log(getUserAgent(), null);
}

public static native String getUserAgent() /*-{
return navigator.userAgent.toLowerCase()
}-*/
}

Everything should work fine but somehow I get these three errors:
Native methods do not specify a body
Syntax error on token ")", { expected after this token
Syntax error, insert "}" to complete ClassBody


Can anyone tell me what is the problem?

Thanks

Olivier Monaco

unread,
Jun 20, 2010, 1:32:26 PM6/20/10
to Google Web Toolkit
Try to add a ";" after the JS comment of getUserAgent:

public static native String getUserAgent() /*-{
return navigator.userAgent.toLowerCase()
}-*/;

Olivier

Shedokan

unread,
Jun 21, 2010, 10:22:08 AM6/21/10
to Google Web Toolkit
Wow, thanks. I thought I would have to start configuring eclipse or
something.

Thanks, I just didn't notice that small ";" at the end.
Reply all
Reply to author
Forward
0 new messages