Skip to main content

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

Toni,

To access the classes in your jar file simply address them using the fully
qualified class name like you did for java.util.Date.  It doesn't appear
that Demo is in the DemoTools package so that line should look like:

var d2 = new Demo();

Trip Gilman


On 6/14/12 7:37 AM, "Toni Rincon" <antonio.rincon@xxxxxxxxx> wrote:

>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:365
>4)
>_______________________________________________
>vtp-dev mailing list
>vtp-dev@xxxxxxxxxxx
>https://dev.eclipse.org/mailman/listinfo/vtp-dev



Back to the top