pyjnius

Pyjnius import jar file

*爱你&永不变心* 提交于 2020-07-05 07:15:52
问题 Pyjnius allows you to create a python wrapper for java classes like: Hardware = autoclass('org.myapp.Hardware') Is there a way to import an existing *.jar file like that? What does the syntax look like? 回答1: You can add the jar into CLASSPATH, then import pyjnius and use autoclass as normal :-): import os os.environ['CLASSPATH'] = "path/to/your.jar" from jnius import autoclass Bla = autoclass('bla.bla.BlaClass') 回答2: As much as jar file relevant only for android, you need to add jar file in

Pyjnius import jar file

拜拜、爱过 提交于 2020-07-05 07:15:49
问题 Pyjnius allows you to create a python wrapper for java classes like: Hardware = autoclass('org.myapp.Hardware') Is there a way to import an existing *.jar file like that? What does the syntax look like? 回答1: You can add the jar into CLASSPATH, then import pyjnius and use autoclass as normal :-): import os os.environ['CLASSPATH'] = "path/to/your.jar" from jnius import autoclass Bla = autoclass('bla.bla.BlaClass') 回答2: As much as jar file relevant only for android, you need to add jar file in

How to use the pyjnius read and write arguments for Bluetooth getInputStream and getOutputStream?

自闭症网瘾萝莉.ら 提交于 2020-01-25 03:59:05
问题 I have been fumbling with getting data from a bluetooth RS232 converter using the python for android jnius library. I had thought that it would be as simple as the PySerial library, but as I am still new to java the implementation is quite different. I created the bluetooth connection quite easily, but as soon as I try to read or write data I get a jnius.jnius.JavaException that No methods matching your arguments, and that the methods available for read are: '()I', '([B)I', '([BII)I' and for

launchservicesd: secTaskLoadEntitlements failed error=22 while loading java

荒凉一梦 提交于 2020-01-06 08:15:06
问题 I am trying to run a python program ( sikuli ) that imports a jar using jnius. This is the gist of the code in sikuli package that loads the jar file in python import os jarpath = "/Users/*/sikuli-api-1.0.3-standalone.jar" os.environ['CLASSPATH'] = jarpath from jnius import autoclass DesktopMouse = autoclass('org.sikuli.api.robot.desktop.DesktopMouse') aa = DesktopMouse() gg = aa.getLocation() This code runs without any problem when I run in windows. But when I run this in mac, the program

kivy android share image

六月ゝ 毕业季﹏ 提交于 2019-12-22 06:27:37
问题 I want to create share button that will use android ACTION_SEND intent for sharing image. It's my code: from kivy.setupconfig import USE_SDL2 def share(path): if platform == 'android': from jnius import cast from jnius import autoclass if USE_SDL2: PythonActivity = autoclass('org.kivy.android.PythonActivity') else: PythonActivity = autoclass('org.renpy.android.PythonActivity') Intent = autoclass('android.content.Intent') String = autoclass('java.lang.String') Uri = autoclass('android.net.Uri'

How To Bundle .jar Files with Pyinstaller

六眼飞鱼酱① 提交于 2019-12-12 12:19:27
问题 How do you get pyinstaller to bundle .jar files as archives for a python project that utilizes them? For instance, to make an exe with (I am using pyjnius for handling the sikuli-standalone jar): # test.py import os import sys # set the classpath so java can find the code I want to work with sikuli_jar = '/sikuli-api.standalone-1.0.3-Pre-1.jar' jarpath = os.path.dirname(os.path.realpath(__file__)) + sikuli_jar os.environ['CLASSPATH'] = jarpath # now load a java class from jnius import