1 Reply Latest reply on Jun 21, 2018 7:56 AM by bungongelo

    KIE Workbench- Script Task- Writing java code and imports

    suchi052

      I'm trying to model my project using KIE Workbench alone ( no eclipse involved)

      I understand that I shouldn't use Script task for complicated process.

       

      However, if I have chosen JAVA as my script language, I believe I should be able to import java classes and write Java code within the Script property.

      However when I try to (import java.util.Random) or try to use Random num = new Random(). It throws me error that it didn't recognize the type Random.

       

      Questions:

      1. Is it possible to develop not too complex business process using KIE workbench alone/solely ( as opposed to doing Jva coding using eclipse)

      2. Can we write normal Java code inside Script task?

      3. How do you propose to generate Random numbers using Data Modeler?

        • 1. Re: KIE Workbench- Script Task- Writing java code and imports
          bungongelo

          I know this is bit of a necro, but I had a similar problem and this is the first result I got. So finally managing to solve the type error I wanted to give my solution.

           

          In the script task it seems (somebody can correct me if I'm wrong) that you can't use imports, but always have to use full paths to each class. In my case I was having problems with using Date and Calendar. This was fixed by writing java.util.Date and java.util.Calendar instead of just Date or Calendar. So for example

           

          Date dateVariable = new Date(); Doesn't work, but should be

           

          java.util.Date dateVariable = new java.util.Date();

           

          I hope this helps some other people who might be having the same kind of troubles.