Python Forum
UPDATING PYTHON TO USE LATEST VERSION OF JAVA?
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UPDATING PYTHON TO USE LATEST VERSION OF JAVA?
#1
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']))
Reply
#2
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.
Reply
#3
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?
Reply
#4
What Operating System are you using?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#5
Windows 7
Reply
#6
Read https://www.java.com/en/download/help/path.xml, and verify the correct java version is listed, if not add the correct path.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#7
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python openyxl not updating Excel file MrBean12 1 249 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  run part of a script with a different version of Python jdog 2 392 Jan-09-2024, 08:49 PM
Last Post: jdog
  How to find out from outside Python (in Windows) the current version of Python? pstein 4 679 Oct-04-2023, 10:01 AM
Last Post: snippsat
  How to resolve version conflicts in Python? taeefnajib 0 873 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  Python venv and PIP version issue JanOlvegg 2 1,199 Feb-22-2023, 02:22 AM
Last Post: JanOlvegg
  Python Version upgrade nitinkukreja 1 851 Feb-04-2023, 10:27 PM
Last Post: Larz60+
  Can't update new python version on Pycharm GOKUUUU 6 3,700 Jul-23-2022, 09:24 PM
Last Post: GOKUUUU
  Building python (3.9.5) with different libexpat version (2.4.6) raghupcr 0 1,257 Feb-25-2022, 11:29 AM
Last Post: raghupcr
  Python keeps running the old version of the code quest 2 3,644 Jan-20-2022, 07:34 AM
Last Post: ThiefOfTime
  Get latest version off website and save it as variable [SOLVED] AlphaInc 5 1,888 Nov-14-2021, 09:00 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020