Python Forum
UPDATING PYTHON TO USE LATEST VERSION OF JAVA? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: UPDATING PYTHON TO USE LATEST VERSION OF JAVA? (/thread-4175.html)



UPDATING PYTHON TO USE LATEST VERSION OF JAVA? - nicklesprout - Jul-27-2017

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']))


RE: UPDATING PYTHON TO USE LATEST VERSION OF JAVA? - micseydel - Jul-27-2017

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.


RE: UPDATING PYTHON TO USE LATEST VERSION OF JAVA? - nicklesprout - Jul-27-2017

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?


RE: UPDATING PYTHON TO USE LATEST VERSION OF JAVA? - sparkz_alot - Jul-27-2017

What Operating System are you using?


RE: UPDATING PYTHON TO USE LATEST VERSION OF JAVA? - nicklesprout - Jul-27-2017

Windows 7


RE: UPDATING PYTHON TO USE LATEST VERSION OF JAVA? - sparkz_alot - Jul-27-2017

Read https://www.java.com/en/download/help/path.xml, and verify the correct java version is listed, if not add the correct path.


RE: UPDATING PYTHON TO USE LATEST VERSION OF JAVA? - nicklesprout - Jul-27-2017

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.