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 3.13(Windows) does not have the latest module OS phillip_from_oz 1 854 Dec-13-2024, 04:35 AM
Last Post: deanhystad
  For Loop assigns only the latest value from List Caliban86 3 1,230 Sep-22-2024, 02:47 AM
Last Post: deanhystad
  How to find out from outside Python (in Windows) the current version of Python? pstein 5 2,334 Jun-28-2024, 07:02 AM
Last Post: Samuel34
  updating pip, python - understanding terminal and pycharm. endlessnameless 0 1,175 Jun-24-2024, 05:48 AM
Last Post: endlessnameless
  run part of a script with a different version of Python jdog 3 2,413 May-27-2024, 01:57 AM
Last Post: Alice12
  Python openyxl not updating Excel file MrBean12 1 2,102 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  How to resolve version conflicts in Python? taeefnajib 0 2,133 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  Python venv and PIP version issue JanOlvegg 2 3,613 Feb-22-2023, 02:22 AM
Last Post: JanOlvegg
  Python Version upgrade nitinkukreja 1 1,735 Feb-04-2023, 10:27 PM
Last Post: Larz60+
  Can't update new python version on Pycharm GOKUUUU 6 7,926 Jul-23-2022, 09:24 PM
Last Post: GOKUUUU

Forum Jump:

User Panel Messages

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