Announcement

Collapse
No announcement yet.

import java libraries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • import java libraries

    I appologize if this sounds like a stupid question, java is not my primary language. Is there a way to import java libraries so that you don't have to type the full namespace out?

    For example, can I import
    org.apache.commons.lang3.StringUtils so that I don't have to type out org.apache.commons.lang3.StringUtils.defaultString every time I want to use that method?

  • #2
    Try
    Code:
    importpackage(org.apache.commons.lang3.StringUtils)
    It's a Rhino function. I've found this to be helpful when trying to use Java in mirth.

    Comment


    • #3
      I think you can also use a variable as a shortcut for the full package name. i.e.
      Code:
      var su = org.apache.commons.lang3.StringUtils;
      var defaultString = su.defaultString("hi");
      Last edited by agradinc; 03-24-2017, 07:03 AM.

      Comment


      • #4
        Your first method failed with the below error message but the second one worked perfectly. Thank you for the assistance. I am reading through the link you provided now.

        DETAILS: ReferenceError: "importpackage" is not defined.

        Comment


        • #5
          Originally posted by ryadical View Post
          Your first method failed with the below error message but the second one worked perfectly. Thank you for the assistance. I am reading through the link you provided now.

          DETAILS: ReferenceError: "importpackage" is not defined.
          The correct method is "importPackage".
          Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

          Nicholas Rupley
          Work: 949-237-6069
          Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


          - How do I foo?
          - You just bar.

          Comment


          • #6
            Originally posted by narupley View Post
            The correct method is "importPackage".
            Thank you, that worked. I was able to get the same results from both of the below lines of code:

            importPackage(org.apache.commons.lang3);
            var StringUtils = org.apache.commons.lang3.StringUtils;

            Comment

            Working...
            X