build
succeeds in IDEA, but automated build
fails
$ ./gradlew
> Task :compileJava FAILED
Wordle/src/game/ui/WordleFrame.java:60: error: illegal start of expression
var background = switch (tallyResultOfOneLetter) {
^
Wordle/src/game/ui/WordleFrame.java:61: error: : expected
case EXACT -> COLOR_OF_EXACT;
^
Wordle/src/game/ui/WordleFrame.java:62: error: : expected
case MATCH -> COLOR_OF_MATCH;
^
Wordle/src/game/ui/WordleFrame.java:63: error: : expected
case NO_MATCH -> COLOR_OF_NO_MATCH;
^
4 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
2 actionable tasks: 2 executed
Later, it was found that the java JDK used in IDEA is 17
, while the automated build in wsl uses JDK 11
, which has not reached JDK14
, so the expression of 14
cannot be recognized.
Then upgrade the JDK in wsl.
Upgrade to Java 17 here.
Specific operation process: Ubuntu 20 under wsl2
first enter
sudo apt update
Specific upgrade process:
Step 1:
sudo add-apt-repository ppa:linuxuprising/java
Step 2:
sudo apt-get update
sudo apt-get install oracle-java17-installer oracle-java17-set-default
The terms that appear, swipe the pagedown
key to the bottom, and use the up, down, left and right keys to select the ok
below
Then press the arrow keys to select yes
, press Enter
Then the download starts
After installation is complete:
$ java --version
java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)