Skip to content

UserfriendlyApiWhitepaper

baztian edited this page Sep 4, 2014 · 3 revisions

Whitepaper for a Userfriendly JPype API

Current jpype API is too complicated and causes lots of user requests to get jpype working. This whitepaper is an attempt to simplify use of jpype with a new API.

Sample session

import jpype
jpype.startJVM() # default without JVM parameters
with jpype: # attach to current Python thread and cleanup afterwards
  jpype.lang.System.out.println("foobar")

API description

jpype.startJVM(classpath=None, jvm_parms=None, jvm_path=None)

honors CLASSPATH system environment variable as java (see man page) does. Prints a warning if startJVM has been started before with different arguments indicating that changed parameters can not be honored classpath: Iterable containing paths to jar files or class folders jvm_parms: Parameters directly passed to java vm jvm_path: Path to jvm so/dll

jpype.shutdownJVM()

Writes a warning that shutdown isn't implemented / functioning. Does not shutdown JVM.

Threading

Do we really need to call jpype.attachThreadToJVM()/jpype.detachThreadFromJVM()? Isn't there a way to do this automatically?