I have written a program in java that controls a Finch robot, using input from a keyboard. The arrow keys control movement, awsd keys control LED colors, and jklm keys control more complicated code like a weather forecast, or a dance. 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. I know jython can be used to use java classes in python, but can I use it the other way around? or is there an easier way to do this?
-
2What are python libraries? Do you mean python modules?Praveen– Praveen2016年01月25日 01:33:53 +00:00Commented Jan 25, 2016 at 1:33
-
I guess your application is a java class, so why don't you import that into jython and feed the data from the Python package to it?Klaus D.– Klaus D.2016年01月25日 01:35:34 +00:00Commented Jan 25, 2016 at 1:35
-
Klaus D., do you mean write a script in Jython that would use both Java and the python, acting like a bridge instead of directly importing the python into the Java program?Jgdabble– Jgdabble2016年01月26日 18:04:43 +00:00Commented Jan 26, 2016 at 18:04
1 Answer 1
No, you cannot use Jython to import Python libs into Java code. If you absolutely have to run some Python from your Java program, you'll need to execute the Python interpreter as another process.