The gwt-maps library is meant to be translated into JavaScript and run inside a browser when it is deployed. You cannot run the code by using a standard JVM and you cannot create a standalone Java application using this API.
If you are indeed writing a web app, for testing, you can run it inside of the GWT hosted mode browser by configuring a GWT module. -Eric. On Mon, Jan 5, 2009 at 11:18 AM, rsoto <[email protected]> wrote: > > Hi I have a piece of code but at run time is giving me this error: > Exception in thread "main" java.lang.ExceptionInInitializerError > at com.google.gwt.maps.client.geocode.DirectionQueryOptions.<init> > (DirectionQueryOptions.java:62) > at com.google.gwt.maps.client.geocode.DirectionQueryOptions.<init> > (DirectionQueryOptions.java:39) > at com.secureorigins.analysis.Route.main(Route.java:22) > Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create > () is only usable in client code! It cannot be called, for example, > from server code. If you are running a unit test, check that your > test case extends GWTTestCase and that GWT.create() is not called from > within an initializer or constructor. > at com.google.gwt.core.client.GWT.create(GWT.java:91) > at > com.google.gwt.maps.client.impl.DirectionQueryOptionsImpl.<clinit> > (DirectionQueryOptionsImpl.java:32) > ... 3 more > > This is the piece of code: > > import com.google.gwt.maps.client.geocode.DirectionQueryOptions; > import com.google.gwt.maps.client.geocode.DirectionResults; > import com.google.gwt.maps.client.geocode.Directions; > import com.google.gwt.maps.client.geocode.DirectionsCallback; > import com.google.gwt.maps.client.geocode.Distance; > import com.google.gwt.maps.client.geocode.Duration; > import com.google.gwt.maps.client.geocode.StatusCodes; > > > /** > * @author rsoto > * > */ > public class Route { > > /** > * @param args > */ > public static void main(String args[]){ > DirectionQueryOptions opts = new DirectionQueryOptions(); > String query = "from: 10424 Eaglestone el Paso tx to: 500 > West > Overland El Paso TX"; > Directions.load(query, opts, new DirectionsCallback() { > > public void onFailure(int statusCode) { > System.out.println("Failed to load > directions: Status " > + > StatusCodes.getName(statusCode) + " " + statusCode); > } > > public void onSuccess(DirectionResults result) { > Distance dis = result.getDistance(); > Duration duration = result.getDuration(); > > System.out.println("The distance is: " + > dis); > System.out.println("The travel duration is: > " + duration); > } > }); > } > } > > Any help will be appreciated. > Thank you, > rsoto > > > > -- Eric Z. Ayers - GWT Team - Atlanta, GA USA http://code.google.com/webtoolkit/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
