title: How to run main method using Gradle from within IntelliJ IDEA?
body: <p>Am new to IntelliJ IDEA (using 2017.1.3) and gradle...</p>
  
  <p>Java file:</p>
  
  <pre><code>package com.example;
  
  public class HelloGradle {
  
      public static void main(String[] args) {
          System.out.println("Hello Gradle!");
      }
  }
  </code></pre>
  
  <p>build.gradle:</p>
  
  <pre><code>group 'com.example'
  version '1.0-SNAPSHOT'
  
  apply plugin: 'java'
  apply plugin: 'application'
  
  mainClassName = "HelloGradle"
  
  sourceCompatibility = 1.8
  
  repositories {
      maven {
          url("https://plugins.gradle.org/m2/")
      }
  }
  
  task(runMain, dependsOn: 'classes', type: JavaExec) {
      main = 'com.example.HelloGradle'
      classpath = sourceSets.main.runtimeClasspath
  }
  
  dependencies {
      testCompile group: 'junit', name: 'junit', version: '4.12'
  }
  </code></pre>
  
  <p>When I click on the run task inside the Gradle Projects window, I get the following:</p>
  
  <p><a href="https://i.stack.imgur.com/r4CIE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r4CIE.png" alt="enter image description here"></a></p>
  
  <p>How can I setup either Gradle or IntelliJ IDEA to print the content in the main method to IntelliJ IDEA's Console view?</p>
  
  <p>Really don't understand why the Console view didn't pop up (from within IntelliJ IDEA and also why it doesn't show me what the error is)...</p>