'Intellij doesn't show run button

Intellij doesn't show run button even if that file is in src folder.

no run button

Maybe do you know what to do?

P. s. It's strange because that file used to show run button but after recloning git repository it just doesn't show any more.



Solution 1:[1]

Right click on src directory and select option Mark Directory As > Sources Root.

Solution 2:[2]

There is an Intellij bug that will result to an intermittent disappearance of that little tiny green run button on the left side of the source code (on same column where the red circle breakpoints are). Yes, you can right-click on the mouse and can do the run via the menu, BUT we love that tiny green button so bring it back!! From time to time, i see this green friend and then suddenly it vanish mysteriously and comes back again. I did all, such as rm -rf .idea and other weird stuff, but no explanation has ever been achieved to explain the vanishing green button and it's sudden re-appearance intermittently.

I am drafting this answer, because all of the above answers seems to claim that there is a logical explanation of the intermittent disappearance of our little green friend and that a sequence of steps exists to make our little green friend re-appear, when in fact, there is no such steps and we just have to accept this is a bug to save the remaining hairs in our scalp.

Solution 3:[3]

In my case Run/Debug buttons disappeared for all projects after updating from IDEA 2019.2 to 2019.3. Tried checking Sources Root, Invalidate Caches, Run/Debug configurations etc - no luck. Only restoring Run/Debug action group helped:

Right click on main toolbar (where the button disappeared) > Customize Menus and Toolbars... > select Run/Debug > Restore Run/Debug.

enter image description here

Solution 4:[4]

I got the same problem with intellij 2019.3 and 2020.1 and found the solution here : https://youtrack.jetbrains.com/issue/IDEA-228180.

Basically, in the IDE the buttons run/debug and the error detection in the code were missing.

The fix was to disable the plugin 'Gradle' (I don't need it anyway) : Settings > Plugins > Gradle and click disable and apply. After restarting your IDE it should work

Solution 5:[5]

I had this issue when building a microservice with SpringBoot. I added a new microservice into the root folder and I could not run it.I am using Maven.

Step:

  • Open pom.xml
  • right click and select "Add as maven project" It should resolve it immediately but you can reload the IDE if it does not update immediately.

Solution 6:[6]

IDE: Idea 2021.2.3

Build tool: Gradle

I removed the .idea and reimported the project from the Gradle source. Worked fine after.

Solution 7:[7]

Another reason could be the Highlighting Level set to None, it should be set at least to Syntax.

Solution 8:[8]

First, make the folder as source root.

Second, make sure you set the project’s sdk correctly. For example, if you set the sdk correctly then import java.util.Scanner can be analyzed by IDEA.

Tip:

  1. try not setting the SDK to IDEA’s bundled JDK. I set the project’s SDK to JDK 11 bundled by IDEA at first then found it couldn’t resolve import java.util.Scanner. Setting to JDK 16 which is installed by the OS’s package manager solved this problem, then the “run” button showed up.

  2. If IDEA can index a java file then the file icon will show with a small “c”, indicating a java class. If not, the file icon will show with a small “j”, as this problem’s image shows, indicating a java file which IDEA doesn’t index.

Solution 9:[9]

Reinstall the IDE, it solved my problem.

Solution 10:[10]

I also applied all these methods but it still didn't work so I stopped my window firewall and allowed access for this application. I don't know how it worked out for me but it just got displayed on top of my screen that window defender firewall has stopped some of this app's features and there was an option to allow so I clicked on it and it now works just fine.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gevorg
Solution 2 eigenfield
Solution 3 Zmiter
Solution 4 Tkim
Solution 5 Slycreator
Solution 6 amer
Solution 7 lainatnavi
Solution 8
Solution 9 enzo
Solution 10 double-beep