Running a Groovy script with a compiled Java class

Blake McBride <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CABwHSOuGKb0ybSBs+BET2apq6C=ghrgHb86rxoV=JqcP=QtEAg@mail.gmail.com>
Greetings,

I can run a simple Groovy class (TestGroovy.groovy) without explicitly
compiling it as follows:

java -jar groovy-3.0.9-indy.jar TestGroovy

I have a compiled Java class file named TestJava.class

I am not using any package declarations.  everything is in the current
directory.

I changed TestGroovy.groovy to call my TestJava.class file, however, this
is what I am getting:

$ java -jar groovy-3.0.9-indy.jar TestGroovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
failed:
/home/blake/groovy/TestGroovy.groovy: 7: Apparent variable 'TestJava' was
found in a static scope but doesn't refer to a local variable, static field
or class. Possible causes:
You attempted to reference a variable in the binding or an instance
variable from a static context.
You misspelled a classname or statically imported field. Please check the
spelling.
You attempted to use a method 'TestJava' but left out brackets in a place
not allowed by the grammar.
 @ line 7, column 3.
    TestJava.javaMethod()
     ^

1 error

I also tried:   java -cp . -jar groovy-3.0.9-indy.jar -cp .  TestGroovy
With the same error.

Basically, I am trying to run a Groovy file and have it call a Java class
that I am supplying.

I am attaching the Java and Groovy files.  Sure appreciate any help.

Blake McBride
TestJava.java (text/x-java, 109 B)
public class TestJava {

	public static void javaMethod() {
		System.out.println("Hello from Java");
	}

}
TestGroovy.groovy (application/octet-stream, 131 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.