title: Compiling Scala Using Maven
body: <p>I want to create a hello world application using maven. </p>
  
  <p>here is my pom.xml:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;ColossusPlay&lt;/groupId&gt;
    &lt;artifactId&gt;ColossusPlay&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.3&lt;/version&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.8&lt;/source&gt;
            &lt;target&gt;1.8&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
          &lt;groupId&gt;com.tumblr&lt;/groupId&gt;
          &lt;artifactId&gt;colossus-metrics_2.10&lt;/artifactId&gt;
          &lt;version&gt;0.8.1-RC1&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>and here is my scala code:</p>
  
  <pre><code>object Main extends App{
    println( "Helo World" )
  }
  </code></pre>
  
  <p>when I run </p>
  
  <pre><code>mvn package
  </code></pre>
  
  <p>it generates a jar file in the target directory. Then what I want to be able to do is run that jar file using</p>
  
  <pre><code>scala target/ColossusPlay-0.0.1-SNAPSHOT.jar
  </code></pre>
  
  <p>However I get NullPointer Exception like this:</p>
  
  <pre><code>java.lang.NullPointerException
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at scala.reflect.internal.util.ScalaClassLoader$$anonfun$tryClass$1.apply(ScalaClassLoader.scala:43)
      at scala.reflect.internal.util.ScalaClassLoader$$anonfun$tryClass$1.apply(ScalaClassLoader.scala:43)
      at scala.util.control.Exception$Catch$$anonfun$opt$1.apply(Exception.scala:119)
      at scala.util.control.Exception$Catch$$anonfun$opt$1.apply(Exception.scala:119)
      at scala.util.control.Exception$Catch.apply(Exception.scala:103)
      at scala.util.control.Exception$Catch.opt(Exception.scala:119)
      at scala.reflect.internal.util.ScalaClassLoader$class.tryClass(ScalaClassLoader.scala:42)
      at scala.reflect.internal.util.ScalaClassLoader$class.tryToInitializeClass(ScalaClassLoader.scala:39)
      at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.tryToInitializeClass(ScalaClassLoader.scala:101)
      at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:63)
      at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
      at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22)
      at scala.tools.nsc.JarRunner$.run(MainGenericRunner.scala:13)
      at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:29)
      at scala.tools.nsc.JarRunner$.runJar(MainGenericRunner.scala:25)
      at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:69)
      at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
      at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
      at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
      at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>The problem appears to be that the maven build does not see the source files. I tried to force it to have a build error writing nonesense to the source file but the mvn package still says build success. Additionaly when I examine the jar file, there isn't any class files inside. How can I make the maven see the source files.</p>