Skip to content

Preview features enabled at an invalid source release level 21, preview can be enabled only at source level 22 #3658

Closed as not planned
@aghasemi

Description

@aghasemi

Hello,

I have Java 21 installed on my machine. I have a maven project for which preview features are enabled (<compilerArgs>--enable-previev</compilerArgs> in the configuration of the compiler plugin).

Previously it worked fine, but now if I try to run a main method in the prject by clicking the play button in the UI (or Run that appears above the method signature), I get the error Preview features enabled at an invalid source release level 21, preview can be enabled only at source level 22 from the VSCode. The error does not happen when I run maven from the terminal (mvn compile).

Explicitly specifying the runtime in the VSCode settings did not solve the issue. Is there anything else I can do?

Thanks

Environment
  • Operating System: Ubuntu 22.04
  • JDK version: 21.0.3
  • Visual Studio Code version: 4.89.0
  • Java extension version: 1.30.0
Steps To Reproduce
  1. Have a maven project with preview features enabled and source version set to 21
  2. Try to run a main() method from the UI.
Current Result

Error Preview features enabled at an invalid source release level 21, preview can be enabled only at source level 22.

Expected Result

Project should build and run as Java 21 is installed on the system

Additional Informations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions