Skip to content

JavaNew

JavaNew["class-name"]

create a JavaObject from the class-name default constructor.

JavaNew["class-name", arg1, arg2,...]

create a JavaObject from the class-name constructor matching the arguments arg1, arg2,...

Note: the Java specific functions which call Java native classes are only available in the MMA mode in a local installation. All symbol and method names have to be case sensitive.

Examples

>> loc = JavaNew["java.util.Locale", "US"]
JavaObject[class java.util.Locale]
>> ds = JavaNew["java.text.DecimalFormatSymbols", loc]
JavaObject[class java.text.DecimalFormatSymbols]
>> dm = JavaNew["java.text.DecimalFormat", "#.00", ds]
JavaObject[class java.text.DecimalFormat]

Calls the format method of the dm Java object.

>> dm@format[0.815] // InputForm
".81"

InstanceOf, JavaClass, JavaNew, JavaObjectQ, JavaShow, LoadJavaClass, SameObjectQ

Implementation status

  • ☕ - supported on Java virtual machine

Github