2

I installed JPype in a correct way and anything is fine and my instalation was succeed but when i run my refactor.py from command prompt i have error that i pointed in title. i hope you can help me for solving this problem. also i have to point that i am beginner in python3.

here is my code:

  import urllib.request
        import os
        import tempfile
        import sys
        import fileinput
        import logging
        import jpype


   logging.basicConfig(filename="ERROR.txt", level= logging.ERROR)
try:
    logging.debug('we are in the main try loop')
    jpype.startJVM("C:/Users/user/AppData/Local/Programs/Python/Python36/ClassWithTest.java", "-ea")
    test_class = jpype.JClass("ClassWithTest")
    a = testAll()
    file_java_class = open("OUTPUT.txt", "w")
    file_java_class.write(a)
except Exception as e1:
        logging.error(str(e1))
        jpype.shutdownJVM()     
saharsa
  • 467
  • 1
  • 7
  • 24
  • How did you install it? Did you maybe accidentally install in a different environment, e.g. for Python 2.7? – kutschkem Mar 05 '18 at 14:26

1 Answers1

1

startJVM() function takes the path to the JVM which is like this - C:\\Program Files\\Java\\jdk-10.0.2\\bin\\server\\jvm.dll. You could use the getDefaultJVMPath() function to get the JVM path on your PC. So you can just start the JVM this way:

startJVM(getDefaultJVMPath(), "-ea")

Hope that helps!

Viseshini Reddy
  • 744
  • 3
  • 13