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?
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?
As much as jar
file relevant only for android, you need to add jar file in your buildozer.spec like
android.add_jars = java/myjar.jar
and in your App's build
method
from kivy.utils import platform
...
if platform() == 'android':
BlaClass = autoclass('java.bla.BlaClass')
...
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')
:
I would assume –
Amlie import jnius_config; jnius_config.set_classpath('/path/to/your.jar')
–
Leboff As much as jar
file relevant only for android, you need to add jar file in your buildozer.spec like
android.add_jars = java/myjar.jar
and in your App's build
method
from kivy.utils import platform
...
if platform() == 'android':
BlaClass = autoclass('java.bla.BlaClass')
...
© 2022 - 2024 — McMap. All rights reserved.