Python Forum

Full Version: UPDATING PYTHON TO USE LATEST VERSION OF JAVA?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
my Java installation is 1.8 but when i run this, it displays version 1.7.. how do i update my python installation to use latest version of java (1.8)?

print(subprocess.check_output(['java', '-version']))
You'd have to specify the full path to the Java version you want, or update your environment variables. I suspect that, even though you have 1.8 installed, if you use "java -version" in a terminal it would say 1.7 just like Python does.
when i run java -version it says 1.8, not 1.7.

can you tell me how to specify the path for Python to use 1.8 instead of 1.7?
What Operating System are you using?
Windows 7
Read https://www.java.com/en/download/help/path.xml, and verify the correct java version is listed, if not add the correct path.
the first two things in my path variable are:

C:\Program Files\Java\jdk1.8.0_141\bin;C:\ProgramData\Oracle\Java\javapath;

like i said, running java works fine for 1.8, i have no clue why python is showing 1.7...

to be more specific, i am running a python script which calls my java Class using POPEN. when i run it, it gives me:

Exception in thread "main" java.lang.UnsupportedClassVersionError: TestClass : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
b''

but when i run the 'java TestClass' in the same cmd prompt, it runs fine.