error: --enable-preview must be used with either -source or --release
The JDK 21 release is well underway likely to drop around September 19th, and its not GA yet. further more it provides preview features.
It was time for downloading one of the releases and giving it a try. Well I have given it a try some weeks ago so I already had it installed. e.g.
openjdk version "21-ea" 2023-09-19 OpenJDK Runtime Environment (build 21-ea+26-2328) OpenJDK 64-Bit Server VM (build 21-ea+26-2328, mixed mode, sharing) The fun thing though is that there are couple of very cool features that are still in preview.