简体   繁体   English

我可以使用jython将python库导入Java代码吗?

[英]Can i use jython to import python libraries into java code?

I have written a program in java that controls a Finch robot , using input from a keyboard. 我已经用Java编写了一个程序,该程序使用键盘输入来控制Finch机器人 The arrow keys control movement, awsd keys control LED colors, and jklm keys control more complicated code like a weather forecast, or a dance. 箭头键控制移动,awsd键控制LED颜色,jklm键控制更复杂的代码,例如天气预报或舞蹈。 Anyway, I am trying to use the CWiid python library and a raspberry pi to use a Wii remote to control the finch, instead of a keyboard. 无论如何,我试图使用CWiid python库和树莓派来使用Wii遥控器来控制雀科,而不是键盘。 I know jython can be used to use java classes in python, but can I use it the other way around? 我知道jython可用于在python中使用java类,但是我可以反过来使用它吗? or is there an easier way to do this? 还是有更简单的方法来做到这一点?

No, you cannot use Jython to import Python libs into Java code. 不,您不能使用Jython将Python库导入Java代码。 If you absolutely have to run some Python from your Java program, you'll need to execute the Python interpreter as another process. 如果绝对必须从Java程序运行某些Python,则需要将Python解释器作为另一个进程来执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM