title: java.lang.NoClassDefFoundError: scala/Function1
body: <p>I tried to start scala application in <code>jar</code>. </p>
  
  <p>The following code:</p>
  
  <pre><code>object Starter {
      def main(args: Array[String]): Unit = {
          args.foreach(path =&gt; {
              val (minX, maxX, minY, maxY) = MainStage.run(path)
              println(minX)
              println(maxX)
              println(minY)
              println(maxY)
          })
      }
  }
  </code></pre>
  
  <p>induces an error on same computer (though it works inside Intellij Idea):</p>
  
  <pre><code>$ java -cp foo-1.0-SNAPSHOT.jar ogr.bar.system.Starter
  Exception in thread "main" java.lang.NoClassDefFoundError: scala/Function1
      at ogr.bar.system.Starter.main(Starter.scala)
  Caused by: java.lang.ClassNotFoundException: scala.Function1
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 1 more
  </code></pre>
  
  <p>Then I tried to make a simple hello world application:</p>
  
  <pre><code>object Starter {
      def main(args: Array[String]): Unit = {
          println("hello world")
          //args.foreach(path =&gt; {
          //      val (minX, maxX, minY, maxY) = MainStage.run(path)
          //      println(minX)
          //      println(maxX)
          //      println(minY)
          //      println(maxY)
          //})
      }
  }
  </code></pre>
  
  <p>And it raises exception:</p>
  
  <pre><code>$ java -cp foo-1.0-SNAPSHOT.jar ogr.bar.system.Starter
  Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$
          at ogr.bar.system.Starter$.main(Starter.scala:7)
          at ogr.bar.system.Starter.main(Starter.scala)
  Caused by: java.lang.ClassNotFoundException: scala.Predef$
          at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          ... 2 more  
  </code></pre>
  
  <p>The following is a fragment of my <code>pom.xml</code></p>
  
  <pre><code>&lt;properties&gt;
      &lt;javaVersion&gt;1.8&lt;/javaVersion&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.scala-lang&lt;/groupId&gt;
          &lt;artifactId&gt;scala-library&lt;/artifactId&gt;
          &lt;version&gt;2.11.8&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.scala-lang.modules&lt;/groupId&gt;
          &lt;artifactId&gt;scala-xml_2.11&lt;/artifactId&gt;
          &lt;version&gt;1.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.scalatest&lt;/groupId&gt;
          &lt;artifactId&gt;scalatest_2.11&lt;/artifactId&gt;
          &lt;version&gt;3.0.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.3&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;${javaVersion}&lt;/source&gt;
                  &lt;target&gt;${javaVersion}&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.scala-tools&lt;/groupId&gt;
              &lt;artifactId&gt;maven-scala-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.15.2&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;compile&lt;/goal&gt;
                          &lt;goal&gt;testCompile&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;sourceDir&gt;src/main/scala&lt;/sourceDir&gt;
                  &lt;testSourceDir&gt;src/test/scala&lt;/testSourceDir&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
      &lt;/plugins&gt;
  &lt;/build&gt;             
  </code></pre>
  
  <p>What should I do to make my app work?</p>