2

I have: Simple Groovy Script: Hello.groovy

    >cat Hello.groovy
    println "Hello ${args[0]}, may Groovy be with you."

which works fine:

    >groovy Hello "Luke Skywalker"
    Hello Luke Skywalker, may Groovy be with you.

I get into trouble running the compiled code.

    >groovyc Hello.groovy
    >java -cp %GROOVY_HOME%/embeddable/groovy-all-2.1.7.jar;. Hello "Luke Skywalker"
    bash: Hello: No such file or directory

(I removed the usage information that also spits out..)

What gives?

Here's some other info:

    >uname -a
    Linux adminuser-VirtualBox 3.8.0-31-generic #46-Ubuntu SMP Tue Sep 10 20:03:44 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

    >file /usr/lib/jvm/default-java/jre/bin/java
    /usr/lib/jvm/default-java/jre/bin/java: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x498bbdda6cbaab7d2c671cf18d378c31021f9ea5, stripped

    >groovy -v
    Groovy Version: 2.1.7 JVM: 1.7.0_25 Vendor: Oracle Corporation OS: Linux
4

1 回答 1

1

You need a colon in the classpath, not a semicolon as you have it in the question:

java -cp %GROOVY_HOME%/embeddable/groovy-all-2.1.7.jar:. Hello "Luke Skywalker"

With a semicolon, you're running two commands:

java -cp %GROOVY_HOME%/embeddable/groovy-all-2.1.7.jar

Followed by

. Hello "Luke Skywalker"

And this line is causing the problem, as bash cannot find a file called Hello to source

于 2013-10-15T18:58:19.323 回答