jython 中的 Java 类
我需要从该脚本访问正在运行 jython 脚本的 java 类? 有什么帮助吗?
更新: 像这样的事情:
//JAVA CLASS
class Test{
public String text;
public Test
{
PythonInterpreter pi = new PythonInterpreter(null);
pi.execfile("test.py");
}
}
所以 int test.py 我需要做一些事情来改变测试类中文本的值
#test.py
doSomething()
Text.test = "new value"
希望它更清楚
I need to access the java class which is running jython script from that script?
Any help?
update:
Something like this:
//JAVA CLASS
class Test{
public String text;
public Test
{
PythonInterpreter pi = new PythonInterpreter(null);
pi.execfile("test.py");
}
}
So int test.py I need to do something to change the value of text in Test class
#test.py
doSomething()
Text.test = "new value"
Hope it is more clear
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要将 java 类实例传递给 嵌入式 jython,您需要执行以下操作:
如果您想从外部脚本调用函数(将实例作为参数):
To pass a java class instance to the embeded jython you need to do:
If you want to call a function (that takes the instance as an argument) from a external script:
您必须在 Jython 代码的顶部导入测试类。 我相信这将类似于
You'll also to set your text value as static, or pass the Java object into the Jython method。
请查看此处文章。
You have to import your test class at the top of your Jython code. I believe this would be something along the lines of
You'll also to set your text value as static, or pass the Java object into the Jython method.
Check out the article here.