Database Reference
In-Depth Information
formatter, and appends to an existing file. When we run this code, we get different sets
of events, in different formats, written to the console and the two different files.
9.5.13 Installing Groovy
After all of this, we hope there are some readers who are eager to install groovy and
begin scripting with it. There are only a few steps.
(1) Install a Java Development Kit (JDK) —If needed, JDks are available for down-
load from oracle. Either the Standard Edition (SE) or the Enterprise Edition (EE) will
do. EE is a superset of SE, with libraries and tools for developing large scale, distributed
applications. Which to get depends on what the developer is planning to do.
(2) S e t J AVA _ H O M E —Setting this environment variable on the development
machine helps groovy find the Java installation. It should point to the root directory of
the JDk, which contains 'bin', 'jre', and 'lib' directories.
(3) Install Groovy —he binary distribution at http://groovy.codehaus.org should
work fine. The Windows installer adds the groovy bin directory to the PAth variable,
'.groovy' to the PAthExt variable, and creates a groovy_homE variable, provided
steps one and two above have been done. Anyone installing in other ways will have to
do those things manually.
(4) Verify installation —First, we enter this command to check if the system can find
the groovy executable.
>groovy --version
This should output a version string from groovy, proving that it is there. now we can test
a small inline program, which will be compiled and run.
>groovy -e "println 'Hello, World!'"
This should print hello, World! to the console.
(5) Put the JAPI directory in CLASSPATH —his is a semicolon delimited environ-
ment variable that lets groovy and Java know where to look for .class and .jar files that
are needed at runtime. We need to create it or modify it to include the JAPI jars. This
example refers to all the .jar files in the directory by using a wildcard character.
C:\Hyperion\products\Essbase\EssbaseClient\JavaAPI\lib\*;
(6) Create a utility library —he need arises from time to time in programming
groovy and Java to incorporate third-party libraries into our programs. to incor-
porate extra .jar files, we can create a directory and add it to the class path variable
described in step five. Adding CLASSPAth entries like the following, in the order
shown, first lets us find all standalone .class and .groovy files, then all .jar files in the
director y.
C:\MyCompany\Batch\lib; C:\MyCompany\Batch\lib\*
We can put an uncompiled file named 'myClass.groovy' containing the code for a class
named 'myClass' into this directory and instantiate that class from other scripts
(7) Find log4j and add it to the utility library —he Essbase JAPI has a third-part
dependency as described in step 6. It does its logging with a package called 'log4j' and
Search WWH ::




Custom Search