I wrote Hello World with JavaFX 11 (OpenJFX) in Liberica JDK 11 and Ported a mini game made with JavaFX to a web browser with GWT. See, I missed GWT, and [Getting Started] I tried (http://www.gwtproject.org/gettingstarted.html), so make a note of it.
I'm getting tired of being consistent with the concept of REST in modern web applications, so I'm wondering if GWT is great for client development. As I wrote in Implementing RSocket communication between server and browser client with Spring Boot and rsocket-js, the emergence of protocols like RSocket and gRPC. Given that, it's amazing that GWT hides client-server communication, albeit legacy. Also, given the existence of languages like TypeScript, GWT's Java-to-JavaScript transpile is amazing.
This article uses the following versions of the tool.
Tool | Version |
---|---|
SDKMAN! | 5.7.4+362 |
Java | 1.8.0_242 |
Maven | 3.6.3 |
Checking at the terminal, it looks like the following.
$ sdk version
SDKMAN 5.7.4+362
$ sdk current java
Using java version 8.0.242.hs-adpt
$ sdk current maven
Using maven version 3.6.3
$ java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
$ mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/takuya/.sdkman/candidates/maven/current
Java version: 1.8.0_242, vendor: AdoptOpenJDK, runtime: /Users/takuya/.sdkman/candidates/java/8.0.242.hs-adpt/jre
Default locale: en_JP, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
Update Homebrew before installing GWT. At the time of writing, GWT 2.8.2 was installed.
$ brew update
$ brew install gwt
Once you've installed GWT, make sure you can use webAppCreator.
$ webAppCreator -help
Google Web Toolkit 2.8.2
...
You can create a new GWT project with the following command. You can create a Maven project with the maven
option. Please note that if you do not give it, it will be an Ant project. Note that the maven
option has been deprecated, and if you use the templates
option instead, you can get the same result with -templates maven, sample, readme
. You can specify the output directory with the ʻoutoption.
com.example.myapp.MyApp` is the module name.
$ webAppCreator -maven -out myapp com.example.myapp.MyApp
Execute with the following command. Note that if you forget the package
, it will not work. I didn't read README.txt properly at first and it didn't work.
$ cd myapp
$ mvn package gwt:devmode
This will launch the following application called GWT Development Mode.
If you click the Launch Default Browser button and display it in the browser, the following screen will be displayed after it is automatically compiled.
When you click the Send button, the result of communication with the server via RPC is displayed in a dialog.
This time I tried Hello World with GWT 2.8.2 and Maven. When it comes to building a proper development environment, Eclipse + GWT Eclipse Plugin or IntelliJ IDEA Ultimate seems to be good. Since I was able to build a development environment with both Eclipse and IntelliJ, I will write an article about how to build such a development environment.
Recommended Posts