Error starting the second JVM if it is already running
I am developing client-server software where the server is python developed. I want to call a group of methods from a java program in python. All java methods exist in one jar file. This means that I don't have to load different jars.
I used jpype for this purpose. For every request from a client, I call a python function that looks like this:
def test(self, userName, password):
Classpath = "/home/DataSource/DMP.jar"
jpype.startJVM(
"/usr/local/java/jdk1.7.0_60/jre/lib/amd64/server/libjvm.so",
"-ea",
"- Xmx512m",
"-Djava.class.path=%s" % Classpath)
NCh = jpype.JClass("Common.NChainInterface")
n = NCh(self._DB_ipAddress, self._DB_Port, self._XML_SCHEMA_PATH, self._DSTDir)
jpype.shutdownJVM()
For one function, it works, but for the second call, it fails to start jvm. I have seen many complaints about this, but I could not find any solution for this. I appreciate it if any body can help.
If jpype has problem in multiple start jvm, is there a way to start and stop jvm once? The server is deployed in an Ubuntu VM, but I don't have enough knowledge to write, for example, a script for this purpose. Could you provide a link or example?
source to share