0

I created a SmartGWT application that displays a UI dialog (shows some controls on a dialog).

This dialog app is tested and works well, but now I have to distribute this as a jar file, so that other SmartGWT projects can use this as a widget.

I am looking at a way, how to ship this component "RemoteFileDialog" as a jar file, so that any other SmartGWT web app can use it for showing a file browser. Is there any detailed document / reference which I can go through to understand fully?

I created the jar file for for this dialog application using jar cvf ... command.

When I use this .jar in a target smartGwt sample project, it is unable to find the classes contained in the .jar

To be sure, I did the following steps in my eclipse ide.

  1. Added the jar to build path via "add external jars"

  2. module inheritance: changes to gwt.xml file

3 Did gwtc to test if the module inherits properly. GWT compile works with no warnings or errors.

However, when I tried to create an instance of dialog class (part of the jar file) in the test code given below, eclipse doesn't recognize or prompt me to add the required import, like the way it does for all other jar files. Code:

Even if I manually add the import statement myself, still it gives compile error at those lines.

I want to a proper way to create a .jar file from a SmartGWT project, so that it can be used as a .jar file in another smartGWT project.

Any help and clues are most appreciated..

This is my environment, if it makes sense:!

SmartGWT 3.0 GWT 2.4 Browser : Firefox 7.0.1 Dev environment: Eclipse Indigo on Ubuntu11.10

regards, RV

Adding the contents of .gwt.xml files...

This one for the widget project file: RemoteFileBrowser.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='remotefilebrowser'>
<!-- Inherit the core Web Toolkit stuff.                        -->
<inherits name='com.google.gwt.user.User'/>

<!-- Inherit the default GWT style sheet.  You can change       -->
<!-- the theme of your GWT application by uncommenting          -->
<!-- any one of the following lines.                            -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

<!-- Other module inherits                                      -->
<inherits name='com.smartgwt.SmartGwt'></inherits>
<inherits name="com.smartgwt.tools.SmartGwtTools"></inherits>
<!-- Specify the app entry point class.                         -->
<entry-point class='com.comviva.remotefilebrowser.client.RemoteFileBrowser'/>

<!-- Specify the paths for translatable code                    -->
<source path='client'/>
<source path='shared'/>

</module>

this one for the host project that uses the widget:file: GWTSample.gwt.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <module rename-to='gwtsample'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />

<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<inherits name="com.smartgwt.SmartGwt" />
<!-- <inherits name="com.comviva.scheduler.SchedulerWidget"></inherits> -->
<inherits name="com.comviva.remotefilebrowser.RemoteFileBrowser"></inherits>
<inherits name="com.smartgwt.tools.SmartGwtTools"></inherits>

<!-- Other module inherits -->

<!-- Specify the app entry point class. -->
<entry-point class='com.rv.gwtsample.client.GWTSample' />

<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />

    </module>
Mopparthy Ravindranath
  • 3,014
  • 6
  • 41
  • 78
  • Can you post your .gwt.xml file ? The one from the project you are trying to create. – Jean-Michel Garcia May 16 '12 at 11:22
  • This one for the widget project: RemoteFileBrowser.gwt.xml – Mopparthy Ravindranath May 16 '12 at 11:55
  • I've posted a partial answer. You could also post the errors you are experiencing – Jean-Michel Garcia May 16 '12 at 12:07
  • 1. The import statement below, shows error in eclipse IDE. > import com.comviva.remotefilebrowser.client.RemoteFileDialog; "The import com.comviva.remotefilebrowser.client.RemoteFileDialog cannot be resolved." 2. Also, the call below shows error. RemoteFileDialog rfDialog = new RemoteFileDialog("*.*, *.htm, *.cpp, *.hpp"); because it cannot recognize the type RemoteFileDialog. – Mopparthy Ravindranath May 16 '12 at 12:20
  • Dear Jean-Michel, Thanx for the link you shared about organizing the folders for GWT. Was extremely useful, and I could understand some fundamentals of .gwt.xml and its attributes. – Mopparthy Ravindranath May 17 '12 at 08:56

2 Answers2

0

In your RemoteFileBrowser.gwt.xml, you can rename the module to a simpler name using :

<module rename-to='com.foo.MyModule'>

Then, when including this "widget" in another project, you do that :

<inherits name="com.foo.MyModule" />

Check this link for more information : https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects

Be carefull, the module name is case sensitive

Jean-Michel Garcia
  • 2,359
  • 2
  • 23
  • 44
  • This is how I am creating a .jar file for my RemoteFileBrowser project. `cd src jar cvf ../RemoteFileDialog.jar com/comviva/remotefilebrowser/client/*.java jar uvf ../RemoteFileDialog.jar com/comviva/remotefilebrowser/shared/*.java jar uvf ../RemoteFileDialog.jar com/comviva/remotefilebrowser/server/*.class jar uvf ../RemoteFileDialog.jar com/comviva/remotefilebrowser/*.xml cd .. jar uvf RemoteFileDialog.jar war/*` – Mopparthy Ravindranath May 16 '12 at 13:05
  • You shouldn't include the war folder. I also have edited my answer – Jean-Michel Garcia May 16 '12 at 14:13
  • I am not getting any module inclusion errors from gwtc. If I compile my host project after including the RemoteFileBrowser.gwt.xml, I do not get any compilation errors, unless I start using the classes contained in the widget project. Because, earlier I have seen these errors and corrected them. Now the problem is only about recognition of the classes within the jar file. OK, will try without including the war folder, but how about the resources (images of widget project), which I want them to be available to the host project? – Mopparthy Ravindranath May 17 '12 at 03:51
0

After a little bit of struggle, I could find out the solution, posting below,as this might be useful for other novices like me :)

  • The way of building the jar file was not correct.
  • Since I created a .jar file manually (not through eclipse) it didn't add the .class files of my RemoteFileDialog under com/comviva/remotefilebrowser/*.class. Instead the class files got added from a location such as /war/WEB-INF/classes.
  • Due to this it was not being recognized even if the .jar was imported.

I now create .jar using eclipse export option and choose the list of files /resources to include.

Mopparthy Ravindranath
  • 3,014
  • 6
  • 41
  • 78