[Solved] Unrecognized VM option 'UseConcMarkSweepGC' When Running the main() in IntelliJ IDEA

There is an old Java project. After I upgrade the version of JDK from 8 to 21 in IntelliJ IDEA, and run the main() method in IntelliJ IDEA, an error occurs.

The error message

Abnormal build process termination: 
nice -n 10 ...
Unrecognized VM option 'UseConcMarkSweepGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Solutions

Remove the unrecognized VM option ‘UseConcMarkSweepGC’ or add “-XX:+IgnoreUnrecognizedVMOptions” in IntelliJ IDEA.

  1. Open Settings.
  2. Click “Build, Execution, Deployment”, and click “Compiler”.
  3. To find “Build process > Shared VM options”.
  4. Remove “-XX:+UseConcMarkSweepGC” or add “-XX:+IgnoreUnrecognizedVMOptions”.
  5. Click the “OK” button.