Wednesday, May 26, 2010

Re: New to java: where do i put new classes?

Well I'm also doing it on App Engine if that adds a 4th learning
curve ;) Java code looks pretty much like C# so I think I can easily
learn that part of it.

I moved the code to the server package. When I start the server I get
this message:

Loading modules
com.mycomp.foo.bar.bar
[ERROR] Unable to find 'com/mycomp/foo/bar/bar.gwt.xml' on your
classpath; could be a typo, or maybe you forgot to include a classpath
entry for source?

I had previously tried moving the "bar" class into it's own package. I
think this is what it is referring to here. However I've since moved
the class to the server package as per your suggestion. So there must
be a reference to this non-existant package some where. Where would I
look?

On May 26, 10:24 am, Alan Chaney <a...@mechnicality.com> wrote:
> Actually, its nothing to do with the Java language explicitly. GWT is
> cleverly organized to make it quick and comparatively easy to build
> sophisticated Ajax apps without having to get too much into the details
> of Javascript.
>
> In a GWT project the GWT compiler cross-compiles a subset of the Java
> language to Javascript for downloading to the client browser.
> You have to tell it which classes to cross-compile and so the GWT
> project layout by convention has three separate sub-packages whose names
> end with 'client', 'server', 'shared'. You can also add sub-packages to
> these.
>
> 'client' and 'shared' packages are both compiled by the JRE for use in
> hosted mode, AND cross-compiled by GWT for use in production mode.
> 'client' is for code ONLY used in the client. 'shared' is for code
> (typically DTOs, or validation objects) which are used on both client
> and server.
>
> You should put classes which are server side only in x.x.x.server or sub
> packages. Then you should make sure that the classpath includes any
> libraries used by these packages by placing the libraries in the
> war/WEB-INF/lib folder and make sure that the JRE looks there.
>
> The exact configuration can be controlled from within a gwt.xml file.
>
> I suggest that you read thehttp://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjec...
> section.
> See also the sections on Modules and Compile and Debug.
>
> Be warned! There's a learning curve in using Java, a STEEP learning
> curve in using Java in web projects and another significant
> learning curve to using GWT for client/server web applications. I
> suggest that you think carefully about the scope  and requirements of
> your application before
> taking these 3 steps. Good luck!
>
> HTH
>
> Alan
>
>
>
> m wrote:
> > Sorry, I'm a c# transplant. I want a create a class that will be used
> > on server side only. In c# I would just create a new class in the
> > project... learning that java doesn't work that way.  I have created a
> > class within the main package of my GWT project (not client, not
> > server, not shared, the main package).  But I don't think this works.
> > It wants to find a .gwt.xml file for this java class.  So... what is
> > the correct way to do this?  Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment