Creates a Java object by calling a constructor from the desired
class. The object is (almost always) stored in the Omegahat session
and a reference to it returned. One must create and initialize the
Java virtual machine before calling this function. See
.JNew is a simple alias of
The name of the Java class to be instantiated. This can be either the full name or a partially qualified name which will use the Omegahat class locator mechanism to find the class. It is better (but less convenient) to give the full name as this avoids the lengthy one-time construction of the class lists in Omegahat. It makes sense to give partially qualified names for a) the user's convenience, b) when one expects to substitute different packages with same-named classes that can be used in place of each other.
the arguments used to identify and be passed to the constructor in the target class being instantiated.
The name to use to store the result in the omegahat named
reference database. If this is missing, an anonymous reference is
returned or the value converted to an R object. If the result of the
Java method can be converted, this argument can be used to prohibit
this conversion and leave the Java value in Omegahat for use in
A character vector of class identifiers that help to identify the Java method to be invoked. This is used to avoid ambiguity introduced by Java's polymorphism/overloaded names and the automatic/implicit conversion performed between R and Java objects.
a logical value indicating whether the Omegahat
interpreter should attempt to convert the newly created object to an
R object (TRUE) or simply leave it in the Omegahat database. This
is ignored if a value for
One can also provide a function which will be called with two
arguments - a reference to the Java object and the class name of the
Java object. This is the same as the function converters one can
Also, one can specify a native routine (i.e. C/C++/Fortran)
address. This can be done using
This creates a new Java object by first converting the R arguments to
Java objects and then looking for a constructor in the target class
that accepts arguments of these types. The resulting Java object is
available for future computations as arguments to
present, the object must be explicitly freed by the caller. This is
always true if a value is given for the
If a value for the argument
.name is provided, this returns a
NamedReference to a Java object stored in the Omegahat session.
Otherwise, usually an
AnonymousReference is returned. However,
if a converter to R exists for the particular Java class being created
and no value for the
.name argument is given in the
call, the Java object will be converted directly to an R object. This
is sometimes useful when the constructor populates the object's fields
and one has no further user for the object itself, but just its
contents. For example, the basic constructor for the class
StatDataURL takes a URL name and reads its contents. A
converter could be registered for this class that returns the lines of
Uses the Omegahat interactive Java environment.
Duncan Temple Lang, John Chambers
1 2 3 4 5 6 7 8 9 10
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.