If you are using IntelliJ IDEA (2025.2 Community Edition)
Edit your running configuration
You should see Build and run
Click modify options to the left
Under the Java section there is add VM options
paste it
click apply run