title: How to start a Scala method from command line?
body: <p>This question may sound a bit stupid, but I couldn't figure out, how to start a Scala method from the command line.</p>
  
  <p>I compiled the following file <code>Test.scala</code> : </p>
  
  <pre><code>package example
  
  object Test {
    def print() {
      println("Hello World")
    }
  </code></pre>
  
  <p>}</p>
  
  <p>with <code>scalac Test.scala</code>.</p>
  
  <p>Then, I can run the method <code>print</code> with <code>scala</code> in two steps:</p>
  
  <pre><code>C:\Users\John\Scala\Examples&gt;scala
  Welcome to Scala version 2.9.2 (Java HotSpot(TM) Client VM, Java 1.6.0_32).
  Type in expressions to have them evaluated.
  Type :help for more information.
  
  scala&gt; example.Test.print
  Hello World
  </code></pre>
  
  <p>But what I really like to do is, to run the method directly from the command line with one command like <code>scala example.Test.print</code>.</p>
  
  <p>How can I achieve this goal ?</p>
  
  <p><strong>UPDATE:</strong>
  Suggested solution by ArikG does not work for me - What I am missing ?</p>
  
  <pre><code>C:\Users\John\Scala\Examples&gt;scala -e 'example.Test.print'
  C:\Users\John\AppData\Local\Temp\scalacmd1874056752498579477.scala:1: error: u
  nclosed character literal
  'example.Test.print'
           ^
  one error found
  
  C:\Users\John\Scala\Examples&gt;scala -e "example.Test.print"
  C:\Users\John\AppData\Local\Temp\scalacmd1889443681948722298.scala:1: error: o
  bject Test in package example cannot be accessed in package example
  example.Test.print
          ^
  one error found
  </code></pre>
  
  <p>where</p>
  
  <pre><code>C:\Users\John\Scala\Examples&gt;dir example
   Volume in drive C has no label.
   Volume Serial Number is 4C49-8C7F 
  
   Directory of C:\Users\John\Scala\Examples\example
  
  14.08.2012  12:14    &lt;DIR&gt;          .
  14.08.2012  12:14    &lt;DIR&gt;          ..
  14.08.2012  12:14               493 Test$.class
  14.08.2012  12:14               530 Test.class
                 2 File(s)          1.023 bytes
                 2 Dir(s)  107.935.760.384 bytes free
  </code></pre>
  
  <p><strong>UPDATE 2 - Possible SOLUTIONs:</strong></p>
  
  <ul>
  <li>As ArikG correctly suggested, with <code>scala -e "import example.Test._; print"</code> works well with Windows 7.</li>
  <li>See answer of Daniel to get it work without the import statement</li>
  </ul>