access a java class from within groovy

前端 未结 1 1439
夕颜
夕颜 2021-02-20 04:26

I have a simple java class:

package test;
class Hello {
  public static void main(String[] args) {
    System.out.println(\"Hi\");
  }
}

on whi

相关标签:
1条回答
  • 2021-02-20 04:46

    Your class Hello needs to be declared as public to be accessible from other packages. As a dynamic language, Groovy can't identify such errors and ends up looking for a variable named Hello.

    It's generally a bad idea to use wildcard imports; in this case, using import test.Hello; would have given you a better error message.

    0 讨论(0)
提交回复
热议问题