Yes, you can do just that. Here's the way to invoke it from Javascript (Source):
How can I call one of my GWT Java methods from my application host page?
In order to accomplish this, you'll
first need to create a JSNI method
that creates a JavaScript method that
in turn makes the call to your Java
method. In your GWT application's
onModuleLoad(), you would call that
JSNI method so that the JavaScript
method is defined. From your
application host page you would then
call the created JavaScript method.
Confused yet? It's actually quite
simple.
The code snippet below shows an
example of this (courtesy of Robert
Hanson):
private native void initPlaylistJS (PlaylistTable pl) /*-{
$wnd.addClipToPlaylist = function (clipId, clipTitle) {
[email protected]::addClip(Ljava/lang/String;Ljava/lang/String;)(clipId, clipTitle);
};
}-*/;
In this example, you would need to
make a call to initPlaylistJS(pl) in
your GWT module's onModuleLoad(). Once
your GWT application loads, the
JavaScript method is defined and is
callable from outside of the GWT
application.
As for the 'baggage', GWT compiles a single monolithic file, so you don't need to include anything else.
One extra thing to note is that in my experience GWT is not perfectly suited for sharing code between the server and the client, since the server part needs to become GWT-compilable, that is only include classes which are part of the emulated JRE or for which you have the source available for compilation.