Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: 'Accessing Java Packages' section added

...

Code Block
languagejs
titleExample: compatible solution
 var file = Packages.java.io.File(files[i]);
 file["delete"]();				// because delete is reserved in javascript

Accessing Java Packages

The following is an example that will cause an initialization error message when used in ECMA script.

Code Block
languagejs
titleExample: Accessing Java Packages
collapsetrue
import sos.net.SOSMail;

However, the following construction shows how new Packages.sos.net.SOSMail(myVariable.smtp()); can be used within a function call as an alternative.

Code Block
languagejs
titleExample: Accessing Java Packages
collapsetrue
function myFunction(){
    
    var params;
    
    var debugParameter = function(paramName) {
        try{
            spooler_log.debug1(".. mail parameter ["+paramName+"]: "+params.value(paramName));
        } catch (e){} //No error handling
    }
    
    try{
        var myVariable = spooler_log.mail();
        this.myObject = new Packages.sos.net.SOSMail(myVariable.smtp());
        ....
    } catch(e){
        throw "Error initializing myObject: "+e;
    }
    ....
}

See also

...