title: Groovy : Unable to resolve class
body: <p>When I run my Groovy script via the command-line or Jenkins, I am getting an "unable to resolve class" error.</p>
  
  <p>I have the following 2 groovy files within the same folder in C:\Users\myuser\git\productname\mycompany-build\src\main\groovy\com\mycompany\build</p>
  
  <p>Foo.groovy</p>
  
  <pre><code>package com.mycompany.build
  
  class Foo {
  
    Foo() {
    }
  
    public void runBar() {
      Bar bar = new Bar();
      bar.name = "my name";
      System.out.println(bar.name);
    }
  
    static void main(String[] args) {
      Foo foo = new Foo();
      foo.runBar()
    }
  }
  </code></pre>
  
  <p>Bar.groovy</p>
  
  <pre><code>package com.mycompany.build
  
  class Bar {
    String name;
  }
  </code></pre>
  
  <p>I run Foo.groovy using the command-line.</p>
  
  <p>I am located within the following directory when I run Groovy:</p>
  
  <pre><code>C:\Users\myuser\git\productname\mycompany-build\src\main\groovy\com\mycompany\build
  </code></pre>
  
  <p>This is what I enter on the command-line (cmd):</p>
  
  <pre><code>C:/java/tools/groovy-2.4.11/bin/groovy -cp C:/Users/myuser/git/myproject/mycompany-build/src/main/groovy/com/mycompany/build Foo.groovy
  </code></pre>
  
  <p>I get the following where it is unable to find the class "Bar", but the Bar.groovy file is in the same directory as Foo.groovy, not to mention that I do specify the -cp as well.</p>
  
  <pre><code>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
  C:\Users\myuser\git\myproject\mycompany-build\src\main\groovy\com\mycompany\build\Foo.groovy: 9: unable to resolve class Bar
   @ line 9, column 9.
         Bar bar = new Bar();
             ^
  
  C:\Users\myuser\git\myproject\mycompany-build\src\main\groovy\com\mycompany\build\Foo.groovy: 9: unable to resolve class Bar
   @ line 9, column 15.
         Bar bar = new Bar();
                   ^
  
  2 errors
  </code></pre>
  
  <p>Can you please advise on how I can get this running from the command-line?</p>
  
  <p>Once I am able to get this running, I plan to run this within a Jenkins job.  I started off attempting to run this within a Jenkins job, but got the same issue which led me to look at running it off the command-line first.</p>
  
  <p>I did attempt this with forward-slashes and back-slashes, but with no difference in behaviour.</p>