Wiki source for FunctionJnew

Show raw source

=====Function jnew=====

This function is part of the [[JavaObjects Java Objects]] support.

**jnew** creates a Java Object

jnew( classname [args ...] )


jnew creates an instance of a java object given its classname and optional constructor arguments.
The classname must be either in one of the packages in the global CLASSPATH or an [[CommandImport imported]] class.

If no additional arguments are provided then the default constructor for the class is used.
Otherwise a constructor matching the types of the supplied arguments is searched for and if found, invoked.
The result is the newly created java object.

Typical use would be to assign this object to a variable or to pass to a function or command.

Example: Create a java.util.Date object and print the unix time.

import commands java
echo date.getTime()


Throws an exception if the class is not found or cannot be constructed.

[[JavaObjects Java Objects]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki