Initializing help system before first use

# Types

## The jvmobject type

You can use the jvmobject type to hold a Java object reference within your Mosel model. A jvmobject initially contains a null reference but can be populated as the return value of jvmcallobj, e.g.:

    declarations
      myobj: jvmobject
    end-decarations
    myobj := jvmcallobj("com.fico.examples.ConfigOperations.getConfigFile","config.dat")

Once the jvmobject is populated, you can check it's populated using getisnull and check if it's of the expected class using getclass, e.g.:

    declarations
      myobj: jvmobject
    end-decarations
    myobj := jvmcallobj("com.fico.examples.ConfigOperations.getConfigFile","config.dat")
    if myobj.isnull then
      writeln('ERROR: Expected configuration File object, found null')
    elif myobj.class<>'java.io.File' then
      writeln('ERROR: Expected configuration File object, found '+myobj.class)
    end-if

You can also turn it to a string or text (which uses the Java toString() method), or pass it to other public Java functions, e.g.:

    declarations
      myobj: jvmobject
      configfiles: array(range) of text
    end-decarations
    myobj := jvmcallobj("com.fico.examples.ConfigOperations.getConfigFile","config.dat")
    configfiles(configfiles.size+1) := text(myobj)
    writeln('About to read configuration from file ',myobj)
    jvmcallvoid("com.fico.examples.ConfigOperations.loadConfigFromFile",myobj);

If the jvmobject contains a java.lang.Number, a java.lang.String or a java.lang.Boolean, you can read the value into a Mosel variable, e.g.:

    declarations
      myobj: jvmobject
      b: boolean
      i: integer
      r: real
      t: text
    end-decarations
    myobj := jvmcallobj("com.fico.examples.ConfigOperations.getConfigValue","value1")
    if myobj.class='java.lang.Integer' then
      i := myobj.intvalue
    elif myobj.class='java.lang.Boolean' then
      b := myobj.boolvalue
    elif myobj.class='java.lang.Double' then
      r := myobj.realvalue
    elif myobj.class='java.lang.String' then
      t := myobj.textvalue
    end-if

You can construct a new Java object and store it in a jvmobject by using the jvmnewobj function, e.g.:

    declarations
      myobj: jvmobject
    end-decarations
    myobj := jvmnewobj("java.io.File","C:/myfiles/mydatafile.csv")

Finally, you can also populate a jvmobject with any of these basic types (the Java object will be created automatically based on the type of the value you provide), e.g.:

    declarations
      i,b,r,t: jvmobject
    end-decarations
    i.value := 1
    b.value := true
    r.value := 9.1
    t.value := 'hello world'

### Attributes

The jvmobject type supports attributes allowing different types of object reference to be read/written:

Attribute | Java type | Mosel type
--- | --- | ---
boolvalue | java.lang.Boolean | boolean
bytevalue | java.lang.Byte | integer
charvalue | java.lang.Character | text
floatvalue | java.lang.Float | real
intvalue | java.lang.Integer | integer
longvalue | java.lang.Long | real
realvalue | java.lang.Double | real
shortvalue | java.lang.Short | integer
strvalue | java.lang.String | string
textvalue | java.lang.String | text

Parent Topic Mosel to Java Module

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.