Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA Java How to make Run configurations automatically select Main Class

My friend and I both have IntelliJ and just want to run plain old java. Every time I make a new java class, I can automatically run it. The configurations just work.

When my friend wants to run it, he has to go to edit configurations and type in the class name. We went through the exact same setup. How do we make it automatically the main function in the class?

Friend's

enter image description here enter image description here

MINE Macbook Pro

Thing

like image 773
Script Kitty Avatar asked Oct 18 '22 18:10

Script Kitty


2 Answers

When you're in a java file that contains a public static final void main(String[] arg) method you can press Ctrl+Shift+F10 to make and run a temporary run configuration for the current class. This can save a bit of time when setting up the configurations.

Alternatively you can try to share the .idea directory with him, as it contains all of the project's settings. I'm not sure what other options will be shared though.

like image 176
Todd Sewell Avatar answered Oct 21 '22 00:10

Todd Sewell


it's easy, Your friend must do this and this setting is changed in the "Default Project Structure..." dialog. Navigate to "File" -> "Other Settings" -> "Default Project Structure...".

Select Default Project Structure

Next, modify the "Project language level" setting to your desired language level.

Setting the project language level

IntelliJ IDEA 12 had this setting in "Template Project Structure..." instead of "Default Project Structure..."

like image 32
Freeman Avatar answered Oct 21 '22 02:10

Freeman