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
public class TestJava {

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

}

Attachment: TestGroovy.groovy
Description: Binary data

Reply via email to