I'm not sure that this is the appropriate place for this question; if it is not, could someone direct me please?
I have been trying to run the following (from "Groovy in Action")
/**
*
*/
/**
* @author syssdc
*
*/
class Money {
private int amount
private String currency
Money (amountValue, currencyValue) {
amount = amountValue
currency = currencyValue
}
// Overide "=="
boolean equals (Object other) {
if (null == other) return false
if (! (other instanceof Money)) return false
if (currency != other.currency) return false
if (amount != other.amount) return false
return true
}
int hashCode() {
amount.hashCode() + currency.hashCode()
}
// Implement "+" operator
Money plus (Money other) {
if (null == other) return null;
if (other.currency != currency) {
throw new IllegalArgumentException (
"cannot add $other.currency to $currency")
}
return new Money(amount + other.amount, currency)
}
}
def buck = new Money(1, 'USD')
assert buck
assert buck == new Money(1, 'USD')
assert buck + buck == new Money(2, 'USD')
It runs fine in the Groovy Console, throws the following from Eclipse when I do "compile groovy" from the File menu:
java.lang.NoClassDefFoundError: org/apache/tools/ant/taskdefs/Java
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.taskdefs.Java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 12 more
Exception in thread "main"
It is entirely possible that I have gotten my Build setup screwed up.
I also get the following error, repeatedly, in a popup dialog:
'Compute launch button tooltip' has encountered a problem. An internal error occurred during 'Compute launch button tooltip'.
The details button yields the following: java.lang.NullPointerException
I am running the latest Eclipse (Version: 3.4.2 Build id: M20090211-1700) and Groovy Plug-in (1.5.7.20081120_2330)
Any help will be greatly appreciated.
Susan