I am not able to compile and run Groovy-scripts. I take a very first example Gold.groovy
. I can compile it with
groovyc Gold.groovy
when I try to start it thereafter with: java Gold
I get the error message
"Fehler: Hauptklasse Gold konnte nicht gefunden oder geladen werden" - which means in english ~ "Main class not found"
Has anybody a hint what I could try or where to find the error?
Thanks in forehand
source
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
for request: screen output
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