Solution: IntelliJ Project SDK was setup as java 23; however the build in command line was using java 17 I changed the SDK in IntelliJ project struct to java 17 and the issue got resolved