Sample IDL Object

The Java createObject method creates an instance of an underlying IDL object and calls its Init method with any specified parameters (see createObject for details). Through this object instance, you have access to the properties and methods of the object as well as the underlying IDL process.

The following samples rely upon an IDL object contained in file named idlexfoo__define.pro. This file must be in the IDL path and needs to contain the following code:

; The Init method expects three parameters:  
; a string, a 32-bit long, and an array which has  
; 2 rows & 3 columns, containing 32-bit long values.   
; The ::Init method can also be called without any parameters. 
 
FUNCTION idlexfoo::Init, parmStr, parmVal, parmArr, _EXTRA=e 
 
   IF (N_ELEMENTS(parmStr) EQ 1) THEN BEGIN 
      IF ( SIZE(parmStr,/type) NE 7 ) THEN BEGIN 
         PRINT, 'IDLexFoo::Init, parmStr is not a STRING' 
         HELP, parmStr 
         RETURN, 0 
      ENDIF 
   ENDIF 
 
   IF (N_ELEMENTS(parmVal) EQ 1) THEN BEGIN 
      IF ( (SIZE(parmVal,/type) NE 3) ) THEN BEGIN 
         PRINT, 'IDLexFoo::Init, parmVal is not a LONG' 
         HELP, parmVal 
         RETURN, 0 
      ENDIF 
   ENDIF 
     
   nElms = N_ELEMENTS(parmArr) 
   IF (nElms GT 0) THEN BEGIN 
      IF ( (nElms NE 6) OR (size(parmArr,/type) NE 3) ) THEN BEGIN 
         PRINT, 'IDLexFoo::Init, parmArr is not a ARR(3,2) ' $ 
         + 'of LONG)' 
         HELP, parmArr 
         RETURN, 0 
      ENDIF 
   ENDIF 
 
   RETURN, 1 
END 
 
; Object definition. 
PRO idlexfoo__define 
   ; Create [col, row] 32-bit long array. 
   initArr = LONARR(3,2)  
   struct = {idlexfoo, $ 
      parmStr: '', $ 
      parmVal: 0L, $ 
      parmArr: initArr $  
   } 
END 

Export the Sample IDL Object

You will need to create the necessary wrapper object files by using the Export Bridge Assistant to generate them. Once you have created the object definition file, idlexfoo__define.pro, complete the following steps:

  1. Open the Export Bridge Assistant by entering IDLEXBR_ASSISTANT at the command line.
  2. Select to create a Java export object by selecting File → New Project → Java and browse to select the idlexfoo__define.pro file. Click Open to load the file into the Export Assistant.
  3. Note
    Export Bridge Assistant details are available in Using the Export Bridge Assistant. Refer to that section if you need more information about the following steps.

  4. The top-level project entry in the left tree panel is selected by default. There is no need to modify the default properties shown in the right-hand property panel, but you can enter different values if desired. There are no other parameters that need to be defined for this object.
  5. Table C-5: Example Export Object Parameters

    Tree View Item
    Parameter Configuration

    IDL Export Bridge Project

    Accept the default value or make changes as desired:

    • Output classname
    • Process name
    • Output directory
    • Package name

    idlexfoo

    Drawable object equals False

  6. Save the project by selecting FileSave project. Accept the default name and location or make changes as desired.
  7. Build the export object by selecting BuildBuild object. The Build log panel shows the results of the build process. A subdirectory, named idlexfoo (based on the object name), contains the .java and .class files, and is located in the Output directory.

See the following for information on how to create this object in your application:

Note on Running the Java Examples

Examples in this sectionprovide Windows-style compile javac (compile) and java (run) commands. If you are running on a platform other than Windows, use your platform's path and directory separators and see Java Requirements for information about the bridge_setup file, which sets additional information.