5

I want to import a class that I made in my project, into my script I did this but it doesn't work:

    function doFunction(){
 //Objectif Mensuel
 importPackage(java.lang);
 importClass(KPDataModel.KPData.KPItem); //ERROR HERE, this is my class that I want to import

 KPItem kpItem = kpItemList.get(0);
 System.out.println(kpItem.CellList.get(2).Value);
 System.out.println("-------");
 var proposedMediationSum = Integer.parseInt(kpItemList.get(0).CellList.get(2).Value);
 var refusedMediationSum = Integer.parseInt(kpItemList.get(0).CellList.get(3).Value)
 var totalMediation = proposedMediationSum + refusedMediationSum;

 kpItemList.get(0).CellList.get(4).Value = totalMediation;

}
Bozho
  • 554,002
  • 136
  • 1,025
  • 1,121
Marouane Gazanayi
  • 4,733
  • 6
  • 35
  • 55
  • Can you post the error you get ? I suspect the KPDataModel.KPData.KPItem is not the fully qualified class name or includes all the classes you want to use. i.e. where is kpItemList defined ? Here is a pretty good tutorial http://java.sun.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html#jsimport – Romain Hippeau Jul 05 '10 at 19:05

1 Answers1

4

Well, thnx a lot, I found that the problem comes from the import. This is what it said in the Oracle website :

The Packages global variable can be used to access Java packages. Examples: Packages.java.util.Vector, Packages.javax.swing.JFrame. Please note that "java" is a shortcut for "Packages.java". There are equivalent shortcuts for javax, org, edu, com, net prefixes, so pratically all JDK platform classes can be accessed without the "Packages" prefix.

So, to import my class I used : importClass(Packages.KPDataModel.KPData.KPItem);

Marouane Gazanayi
  • 4,733
  • 6
  • 35
  • 55