Playground of using the JPype
- Write java source
- Build java source to class
javac <source_file> -d <Project_dir>/java/bin
Require) The arch of python interpreter have to be same with the jdk. (32bit / 64bit)
- Set classpath
- Run JVM
jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)
- Get package
package_py = jpype.JPackage(<package_name>
- Get class
class_py = package_py.<class_name>
- Get instance
instance_py = class_py()
- Use method
instance_py.<method_name>
- Shutdown JVM
jpype.shutdownJVM()