开发者

Import a class in Scripting java (javax.script)

I want to import a class tha开发者_如何学JAVAt 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;

}


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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜