How to Use JQuery in GWT

After adding the JQuery script to your project HTML file’s header section

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

You will be able to use JQuery in native (JSNI) methods by prepending $wnd., e.g.:

private native void someMethod() /*-{
	$wnd.$(function() {
		$wnd.$('#somediv').doSomething();
	});
}-*/;

Without $wnd. you will end up with following error: com.google.gwt.core.client.JavaScriptException: (ReferenceError): $ is not defined