O'Reilly logo

SAS 9.4 Language Reference, 6th Edition by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Java Object
About the Java Object
The Java object provides a mechanism that is similar to the Java Native Interface (JNI)
for instantiating Java classes and accessing fields and methods on the resultant objects.
You can create hybrid applications that contain both Java and DATA step code.
CLASSPATH and Java Options
In previous versions of SAS, Java classes were found using the JREOPTIONS system
option.
In SAS, you must set the CLASSPATH environment variable so that the Java object can
find your Java classes. The Java object represents an instance of a Java class that is
534 Chapter 22 Using DATA Step Component Objects
found in the current Java classpath. Any class that you use must appear in the classpath.
If the class is in a .jar file, then the .jar filename must appear in the classpath.
How you set the CLASSPATH environment variable depends on your operating
environment. For most operating systems, you can set the CLASSPATH environment
variable either locally (for use only in your SAS session) or globally. Table 22.1 on page
535 shows methods and examples for different operating environments. For more
information, see the SAS documentation for your operating environment.
Table 22.1 Setting the CLASSPATH Environment Variable in Different Operating
Environments
Operating
Environment Method Example
Windows
Globally Windows System
Environment Variable
in Control Panel
Control Panel ð System ð Advanced ð
Environment Variables (Windows XP Classic
view)
SAS configuration file
set classpath c:\HelloWorld.jar
Locally SAS command line
-set classpath c:\HelloWorld.jar
UNIX
Globally SAS configuration file
set classpath ~/HelloWorld.jar
Locally
EXPORT command
*
export classpath=~/HelloWorld.jar;
z/OS
Globally TKMSENV data set
set TKJNI_OPT_CLASSPATH=/u/userid/java:
/u/userid/java/test.jar: asis
Locally Not available
VMS
Globally
Command line
**
$ define java$classpath disk:[subdir]
abc.jar, disk:[subdir2]def.jar
detach_template.com
script that is generated
in sas$root:
[misc.base] at
installation
define java$classpath disk:[subdir]
abc.jar, disk:[subdir2]def.jar
Locally Not available
*
The syntax depends on the shell.
**
The command line should be defined before you invoke SAS so that the process that the JVM actually
runs in gets the definition as well.
Using the Java Object 535

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required