Groovy not reading jar files in .groovy / lib

I have a problem with jar and groovy files. For a few specific examples, I try to connect to the postgresql database, and when sql = Sql.newInstance("jdbc:postgresql://localhost", "user", "pass", "org.postgresql.Driver") I use it, I get a ClassNotFound exception for org.postgresql.Driver. I have a postgresql jar in my $ {user.home} /. Groovy / lib, and the line to load from there to groovy -starter.conf is not commented out. I also have a similar problem with the dbunit.jar file.

If I try to manually add the classpath using groovy -cp, I get an error Caught: java.io.UnsupportedEncodingException: p

Any ideas?

+3
source share
1 answer

According to CLI Help - http://groovy.codehaus.org/Groovy+CLI :

$groovy -help
usage: groovy
 -a,--autosplit <splitPattern>   automatically split current line
                                 (defaults to '\s')
 -c,--encoding <charset>    specify the encoding of the files
 -e <script>               specify a command line script
 -h,--help                 usage information
 -i <extension>            modify files in place
 -l <port>                 listen on a port and process inbound lines
 -n                        process files line by line
 -p                        process files line by line and print result
 -v,--version              display the Groovy and JVM versions

groovy -cp groovy p, .

${user.home}/.groovy/lib , , ${user.home}. , , .

WA - CLASSPATH , .

Windows: set CLASSPATH=c:\temp\postgresql.jar;c:\temp\dbunit.jar ... Unix/Linux (KSH): export CLASSPATH=${HOME}/temp/postgresql.jar:${TEMP}/temp/dbunit.jar ...

+1

All Articles