Could not successfully Import class in Groovy? -
i created 2 class named vendor , address in 1 file called business.groovy(that created package using name business) , in same folder created groovy code imports business package , make use of vendor class attributes(vendor class in business package). when try create object vendor in groovy script, throwing error stating that:
/home/anto/groovy/pakg/imports.groovy: 2: unable resolve class vendor @ line 2, column 13. def canoo = new vendor()
what have do? did go wrong?
these files created: business.groovy
package business class vendor { public string name public string product public address address = new address() } class address { public string street, town, state public int zip }
impottesting.groovy
import business.* def canoo = new vendor() canoo.name = 'canoo engineering ag' canoo.product = 'ultralightclient (ulc)'
and when try execute importtesting.groovy file using groovy importtesting command, error mentioned before!
i suggest either use build tool ant or gradle, or ide intellij idea control classpath/compilation/runtime needs.
edit: should that:
basedir/business/business.groovy basedir/impottesting.groovy
your compiled classes should resemble same directory structure:
basedir/business/business*.class basedir/impottesting*.class
then basedir should added classpath.
Comments
Post a Comment