3

Is there a way to check the connection between jpype and java other than a print statement? I have installed jpype in anaconda (Windows 10 64bit, anaconda python27 (64bit) and jpype from the anaconda cloud). I can import jpype and create javaclasses and javaojects. However, when I try to get a print statement nothing happens and I can't figure out why.

from jpype import *
getDefaultJVMPath()

Out[2]: u'C:\\Program Files\\Java\\jre1.8.0_131\\bin\\server\\jvm.dll'

startJVM(getDefaultJVMPath(), "-ea")
java.lang.System.out.println("JPYPE WORKS !")

No print statement

javaPackage = JPackage("java.lang")
javaClass = javaPackage.String
javaObject = javaClass("Hello, Jpype")
javaObject

Out[8]: <jpype._jclass.java.lang.String at 0xc1b8b70>

java.lang.System.out.println(javaObject)

No print statement

The getDefaultJVMPath() is correct. But I can't get the connection with the jvm to work and I can't figure out where it goes wrong. Any suggestions?

D.Vrebos
  • 31
  • 1

1 Answers1

0

That's the case when you're using Jupyter Notebook. It works well if you're executing it in Python console or by using a .py file. If you're wondering why it worked for getDefaultJVMPath(), here is why

type(getDefaultJVMPath()) 

returns 'str'. But

type(java.lang.System.out.println("JPYPE WORKS !"))

returns 'NoneType'

Hope that helps!

Viseshini Reddy
  • 744
  • 3
  • 13