IntelliJ run single Java file
Another option could be useful and quick for you. Just write your class with main
method you want to run, and then press a little green triangle either behind your main
method or behind your class name:
After that you will be able to choose an option e.g., Run, Debug or Run with Coverage:
In this case IDEA will just run your class without building the entire project.
You can change the Default settings based on your needs, to either automatically build after each change or manually. This can be achieved by clicking on File
-> Other Settings
-> Default Settings
. This is the popup window.
To change the run configurations, you can follow below steps.
- Goto
Run
tab at the top Toobar and click onEdit Configurations
. - Click
+
icon and selectApplication
. This opens a new popup window where you can add all your VM arguments & Program arguments similar to Eclipse.