gpt4 book ai didi

java - 在 Scripting java (javax.script) 中导入一个类

转载 作者:搜寻专家 更新时间:2023-10-31 20:16:07 25 4
gpt4 key购买 nike

我想将我在项目中创建的类导入到我的脚本中我这样做了,但它不起作用:

    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;

}

最佳答案

嗯,非常感谢,我发现问题出在导入上。这是它在 Oracle 网站上所说的:

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.

因此,为了导入我使用的类:importClass(Packages.KPDataModel.KPData.KPItem);

关于java - 在 Scripting java (javax.script) 中导入一个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3180188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com