Flash Advertise
| Create dynamic applications with javax.tools |
|
| From: IBM developerWorks Worldwide read times: 130 |
Provided by yangyi at 2007-12-23 19:39:57 |
Level: Intermediate David J. Biesack (David.Biesack@sas.com), Principal Systems Developer, SAS Institute, Inc.
11 Dec 2007 Many of today's applications require dynamic capabilities, such as
enabling users to supply an abstract form of computation that extends an application's
static capabilities. The javax.tools package, added to
Java™ Platform, Standard Edition 6 (Java SE) as a standard API for compiling
Java source, is a superb way to achieve this goal. This article provides an overview of
the major classes in the package, demonstrates how to use them to create a façade
for compiling Java source from Java Strings instead of files,
and then uses this façade to build an interactive plotting application.
Introduction
The javax.tools package, added to Java SE 6 as a standard API for compiling Java source, lets you add dynamic capabilities to extend static applications. This article provides an overview of the major classes in the package and demonstrates how to use them to create a façade for compiling Java source from Java Strings, StringBuffers, or other CharSequences, instead of files. It then uses this façade to build an interactive plotting application that lets the user express a numeric function y = f(x) using any valid numeric Java expression. Finally, it discusses the possible security risks associated with dynamic source compilation and ways to deal with those risks. ...... Please access the below link to view the full content. Original link: http://www.ibm.com/developerworks/java/library/j-jcomp/?S_TACT=105AGX54&S_CMP=A1214&ca=dnw-848
|