Does GWT really compile client code for JavaScript and HTML?

I have serious doubts about using GWT. GWT claims that the client codes are compiled in JavaScript and HTML, but after compiling the code, I still see the .class files for the client code in my project. Of course, I have some js and html files in the WEB-INF directory, but if the java client code is fully compiled into js and html, why should there be .class files in the project?

+4
source share
2 answers

It is very simple if you know what GWT is. According to Wikipedia:

GWT applications can be launched in two modes:

  • Development Mode (formerly Hosted mode):. The application runs as Java bytecode in the Java Virtual Machine (JVM). This mode is commonly used for development, supporting hot-swapping code and debugging.
  • Production mode (formerly web mode):. The application runs as pure JavaScript and HTML compiled from a Java source. This mode is commonly used for deployment.

I think you understand why you see Java bytecode (.class) files in your project. To verify it: run your project and open the web page that gwt generates, remove the .class files from the client package, and this will not work. But in production mode, it works correctly, since it does not depend on some .class files. For example, classes that are responsible for building the user interface.

+4
source

When deployed to GAE, you will see the "WAR" directory. This WAR is what is deployed on the server and has pure JS + HTML code for client-side code.

0
source

Source: https://habr.com/ru/post/1396375/


All Articles