user343037 user343037 - 1 year ago 130
Java Question

Running Projects in IntelliJ

I've got a project from my teacher, in which i should add my implementation for a certain aspect.

The Project already got a

method but still the "Run" and "Debug" buttons in the top right corner are greyed out.

I've also tried right clicking the main method and java file, but it doesnt show me run or debug.

Also tried using the "Make Project" Button (top right corner), but it doesnt let me run it either.

How can i run the project?

Help would be much appreciated cause I cant seem to find a solution...

Answer Source

the "run" and "debug"-button in the top run the currently selected main-method. As long as you haven't selected one, you can't run it. In the current version on the left side of the editor-pane, there should be a green arrow right next to the main-button. Run it once via clicking that arrow and from that point on you can run/debug the program using the buttons on the top-window.

enter image description here

In this image you can see the green arrows (version 2016.2.4).

Alternatively, you can use the following more complicated, but also more versatile option:
Directly from the run- and debug-buttons is a button that toggles a list. In the initial configuration of the project, this list contains exactly one Item: "Edit Configurations...". Use it to create a custom-target - go for Application, if your using a java-class as entry-point - and set up the configuration as you wish. Clicking the arrow mentioned earlier does basically the same with a bit of automatic configuration.

Third alternative:
Open the context-menu on the main-method. It as well contains options to run and debug the program with the marked method as entry-point. Works for the context-menu of the respective class as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download