title: Using gradle to build a very simple java program
body: <p>I am new to Java and Gradle, and have a very newbie question.  I have the following Java file:</p>
  
  <pre><code>public class TestMain {
      public static void main(String[] args) {
          System.out.println("Hello.....");
      }
  }
  </code></pre>
  
  <p>I am able to compile the above file using javac, and run it using command "java TestMain".</p>
  
  <p>I am now trying to do the same using gradle build framework.  I performed the following steps:
      run "gradle init --type java-library
      copied the above file into src/main/java/</p>
  
  <p>When I run "./gradlew build", I get a TestMain.class file, and a also a "building-java-file.jar"  (the whole gradle directory is in building-java-file directory).</p>
  
  <pre><code>$ ls -l build/classes/main/TestMain.class 
  -rw-r--r--  1 user1  foo\eng  610 May 22 17:22 build/classes/main/TestMain.class
  
  $ java  build/classes/main/TestMain
  Error: Could not find or load main class build.classes.main.TestMain
  </code></pre>
  
  <p>How do I run the TestMain.class?
  Also, what is the reason for gradle creating the jar file - building-java-file.jar?</p>
  
  <p>Btw, my build.gradle file is pretty empty.</p>
  
  <pre><code>apply plugin: 'java'
  
  repositories {
      jcenter()
  }
  
  dependencies {
      // The production code uses the SLF4J logging API at compile time
      compile 'org.slf4j:slf4j-api:1.7.21'
  
      testCompile 'junit:junit:4.12'
  }
  </code></pre>
  
  <p>Thank you,
  Ahmed.'</p>