Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[vtp-dev] execute java code in jar from script module

I am trying to inclode java code developped in external project as a
jar in dependencies folder.
But when executing the script the classes and methods in in jar are
not available.
Is it possible to execute code developped in other java projects from
the script module? How is it done?

Thanks.

Toni

Code in DemoTools.jar
--------

import java.util.Date;

public class Demo {
      public void date(){
              Date d = new java.util.Date();
              System.out.println("date: " + d);
      }

      public static void main(String [ ] args)
      {
            Demo d = new Demo();
            d.date();
      }
}


Code in the script module
-------------------------------
var d = new java.util.Date();
Log.info('date: ' + d);

var d2 = new DemoTools.Demo();
d2.date();

Error in Tomcat logs
-------------------------------
INFO|2012/06/13|17:06:57|p=Demo2|s=9C0D97CF472BF12731F0768ED4F3F823|e=0001>
Action "Script" Starting
INFO|2012/06/13|17:06:58|p=Demo2|s=9C0D97CF472BF12731F0768ED4F3F823|e=0001>
Executing script...
INFO|2012/06/13|17:06:58|p=Demo2|s=9C0D97CF472BF12731F0768ED4F3F823|e=0001>
date: Wed Jun 13 17:06:58 CEST 2012
org.mozilla.javascript.EcmaError: ReferenceError: "DemoTools" is not defined.
      at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)


Back to the top