Forums

Use methods of a jar file

Hello I want to use methods that are in a .jar file is there any way I can do it using python? thanks

I don't think so -- stuff in a jar file is written using Java, so I can't see any way you can call that without running Java yourself. You could perhaps call Java in a subprocess from Python, but unfortunately that won't work on PythonAnywhere unless it's in a specially-configured console -- it won't work in a website's code or in a scheduled task. If you only want to call it from a console, we can switch you over to the system that will allow that -- just let us know.

There are a few ways to mix Python and Java. The most obvious is Jython which is Python running on the JVM. If your Python is fairly self sufficient then it all works smoothly. There are issues if you also want to drag in third party Python packages which use native libraries.

True. But, again, Jython (because it depends on the JVM) won't work in scheduled tasks or websites on PythonAnywhere.