我無法編譯和運行Groovy腳本。我拿第一個例子Gold.groovy
。我可以 groovyc的Gold.groovygroovyc似乎不編譯,類不可運行
編譯它,當我嘗試之後開始它: java的黃金
我得到錯誤信息
"Fehler: Hauptklasse Gold konnte nicht gefunden oder geladen werden" - which means in english ~ "Main class not found"
有沒有人暗示什麼,我可以嘗試或在哪裏可以找到錯誤?
感謝正手
源
List fibo = [1, 1] //#A
List gold = [1, 2] //#B
while (! isGolden(gold[-1])) { //#C
fibo.add(fibo[-1] + fibo[-2]) //#D
gold.add(fibo[-1]/fibo[-2]) //#E
}
println "found golden ratio with fibo(${ fibo.size-1 }) as"
println fibo[-1] + "/" + fibo[-2] + " = " + gold[-1]
println "_" * 10 + "|" + "_" * (10 * gold[-1])
def isGolden(candidate) { //#F
def small = 1 //#G
def big = small * candidate //#H
return isCloseEnough((small+big)/big, big/small)
}
def isCloseEnough(a,b) { return (a-b).abs() < 1.0e-9 }
//#A Initial Fibonacci numbers
//#B Golden ration candidates
//#C Last gold candidate
//#D Next fibo number
//#E Next golden candidate
//#F Candidate satisfies golden rule
//#G Smaller section
//#H Bigger section
用於請求:屏幕輸出
D:\work\groovy\GroovyInAction-master\listings\chap01>set CLASSPATH
CLASSPATH=.;D:\DevTools\groovy-2.4.7\embeddable\groovy-all-2.4.7.jar
D:\work\groovy\GroovyInAction-master\listings\chap01>type HelloWorld.groovy
println "Hello World"
D:\work\groovy\GroovyInAction-master\listings\chap01>groovyc HelloWorld.groovy
D:\work\groovy\GroovyInAction-master\listings\chap01>java WelloWorld
Fehler: Hauptklasse WelloWorld konnte nicht gefunden oder geladen werden
D:\work\groovy\GroovyInAction-master\listings\chap01>javac -cp .;D:\DevTools\gro
ovy-2.4.7\embeddable\groovy-all-2.4.7.jar HelloWorld
error: Class names, 'HelloWorld', are only accepted if annotation processing is
explicitly requested
1 error
嗨,你可以提供一個[MCVE] –
我已添加信息來源 – toohoo