aspose file tools*
The moose likes GWT and the fly likes Trying to use non-GWT jar in GWT project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Trying to use non-GWT jar in GWT project" Watch "Trying to use non-GWT jar in GWT project" New topic
Author

Trying to use non-GWT jar in GWT project

John Danek
Greenhorn

Joined: Jun 12, 2009
Posts: 25
I have a GWT application, foo, that imports a jar (bar) I previously made that is solely Java. In the jar, I have a folder src/ in the top level that contains all of the source code. Yet, when I try to build foo, I get the error:

[java] [ERROR] Line 185: No source code is available for type bar; did you forget to inherit a required module?

Since bar is not a GWT application, I don't know what to do. I know using an "inherit" tag would help in foo's foo.gwt.xml, but bar isn't GWT. What to do to get it to work? I've scoured the web and this forum for a solution but have yet to find anything. Is there a way to tell the GWT compilier that the source is located in bar.jar's src/ folder?

Any help is greatly appreciated!
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

I'm a little rusty here but I will do my best:
In order to be able to use third party code in your GWT client page, GWT should translate it to JavaScript.
So you can take the source you want to use and put it in the directory that GWT will translate it to JavaScript (I don't remember what was its name).
BTW, GWT official docs discuss this pretty well, check it.
John Danek
Greenhorn

Joined: Jun 12, 2009
Posts: 25
Thanks for your response!

GWT translates all of the Java source code in the package "client" to JavaScript. In my case, one of these classes uses bar. The project has the jar on its build path, and the jar has the source code in it. I'm just wondering if there's a way to tell GWT that "bar's source code is in bar.jar." That way, everyone implementing my jar in their GWT project doesn't have to manually create a client.bar subpackage and put the source code there.

Anyways, I'm currently trying to just send a RPC to a server where bar will be used, circumventing the need for compiling it in client, but this is rather tedious.

Does anyone know if my wished-for method is possible?
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

I may be wrong but as you are using class from boo.jar in you client code, you have to put the source under client directory so GWT can translate it.
Federico Kereki
author
Ranch Hand

Joined: Aug 27, 2010
Posts: 31
Hi!

You must have the source code for the JAR; otherwise, GWT won't be able to compile it into JavaScript.

When you build modules for GWT (GWT code, for use in other GWT projects) you have to include the source code; I dealt with this in Chapter 15, "Modules", in ESSENTIAL GWT.

Hope this helps!

Great fan of Open Source, Linux, and web development with GWT; all of these come together for my ESSENTIAL GWT book!
Federico Kereki
author
Ranch Hand

Joined: Aug 27, 2010
Posts: 31
John Danek wrote:
GWT translates all of the Java source code in the package "client" to JavaScript.


Just a little detail: With the latest GWT 2 versions, there's also a "shared" package, for code that is supposed to be used both client- and server-side.

Hope this helps!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to use non-GWT jar in GWT project