Add Java packages to GWT

I've tried to search, but I can't figure out how to add my package to the GWT project

My tree structure is as follows:

-com.mycompany
  -public
    MyApplication.html
  MyApplication.gwt.xml


-com.mycompany.client
  MyApp.java

-com.mycompany.gui
  TableLayout.java

The answer I saw there was, relative to GWT Add a package to the root directory of the XML file, like this:

<module>
  <inherits name="com.google.gwt.user.User" />
  <entry-point class="com.mycompany.client.MyApp" />
  <source path="client" />
  <source path="gui" />
</module>

Then complain:

Unable to find type 'com.technicon.client.MyApp'
   Hint: PrevIoUs compiler errors may have made this type unavailable
   Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly

Anyone can tell me what I'm doing wrong and how to solve this problem?

Solution

You can get rid of two source path lines, because by default, GWT will pick up anything related to the root and the content in the client package You also need to move your GUI package to your client package, which will become:

-com.mycompany
  -public
    MyApplication.html
  MyApplication.gwt.xml


-com.mycompany.client
  MyApp.java

-com.mycompany.client.gui
  TableLayout.java


<module>
  <inherits name="com.google.gwt.user.User" />
  <entry-point class="com.mycompany.client.MyApp" />
</module>

Suppose your myapp Java is an actual entrypoint, so this should be normal

It should also be noted that you cannot use Java classes that do not belong to the GWT JRE emulation library. If you do, your project will not compile You should get very specific mistakes For example, if you don't simulate them, you can't use things like Java math. Library classes like BigDecimal All your own classes you create can be used

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>