🌐
Jython
jython.org
Home | Jython
import org.python.util.PythonInterpreter; public class JythonHelloWorld { public static void main(String[] args) { try(PythonInterpreter pyInterp = new PythonInterpreter()) { pyInterp.exec("print('Hello Python World!')"); } } } from java.lang import System # Java import print('Running on Java version: ' + System.getProperty('java.version')) print('Unix time from Java: ' + str(System.currentTimeMillis())) Ready to get started? Head over to Downloads.
Java implementation of the Python interpreter
Jython Logo
Jython is an implementation of the Python programming language designed to run on the Java platform. It was known as JPython until 1999. Jython programs can import and use any Java class. … Wikipedia
Factsheet
Initial release January 17, 2001; 25 years ago (2001-01-17)
Stable release 2.7.4
/ 18 August 2024; 19 months ago (18 August 2024)
Written in Python and Java
Factsheet
Initial release January 17, 2001; 25 years ago (2001-01-17)
Stable release 2.7.4
/ 18 August 2024; 19 months ago (18 August 2024)
Written in Python and Java
🌐
PyPI
pypi.org › project › install-jdk
install-jdk · PyPI
If not specified, will install into $HOME/.jdk/<VERSION> for the Java Development Kit and $HOME/.jre/<VERSION> for the Java Runtime Environment. vendor - The vendor to download the OpenJDK build from. If not specified, defaults to Adoptium.
      » pip install install-jdk
    
Published   Jul 21, 2023
Version   1.1.0
🌐
Python
python.org › downloads
Download Python | Python.org
Python 3.14.2 Dec. 5, 2025 Download Release notes
🌐
pytz
pythonhosted.org › javabridge › installation.html
Installation and testing — python-javabridge 1.0.12 documentation
The Windows build is tested with the Oracle JDK 1.7. You also need to install the Java Runtime Environment (JRE). Note that the bitness needs to match your python: if you use a 32-bit Python, then you need a 32-bit JDK; if you use a 64-bit Python, then you need a 64-bit JDK.
🌐
GitHub
github.com › ninia › jep
GitHub - ninia/jep: Embed Python in Java · GitHub
Both Java and Python are cross platform, enabling deployment to different operating systems. Simply run pip install jep or download the source and run pip install .. Building and installing require the JDK and Python, to be installed beforehand.
Starred by 1.5K users
Forked by 163 users
Languages   C 52.1% | Java 30.2% | Python 17.7%
Find elsewhere
🌐
PyPI
pypi.org › project › jdk4py
jdk4py · PyPI
Download URL: jdk4py-21.0.8.0-py3-none-manylinux_2_17_x86_64.whl
      » pip install jdk4py
    
Published   Oct 14, 2025
Version   21.0.8.0
🌐
Jython
jython.org › download.html
Downloads | Jython
Home News Download · Documentation · Installation JavaDoc APIdia (alternative to JavaDoc) Python 2.7 Jython Book Wiki Archived Sites · Development · Bug tracker Github Legacy Mailing List Developer Guide Jython 3 Features (MVP) Jython 3 Roadmap Jython 3 (snapshot) on APIdia Website source Links ·
🌐
Readthedocs
jpy.readthedocs.io › en › latest › install.html
Installation — jpy 0.9.0 documentation
Download and install Windows SDK 7.1 SP1. ... SET DISTUTILS_USE_SDK=1 SET JDK_HOME=<path to the JDK installation directory> SET JAVA_HOME=%JDK_HOME% SET PATH=%JDK_HOME%\jre\bin\server;%PATH% Then, to actually build and test the jpy Python module use the following command:
🌐
UCI ICS
ics.uci.edu › ~pattis › common › handouts › pythoneclipsejava › java.html
Java Download and Installation Instructions
The installed files are typically stored (in Windows) in the folder C:\Program Files\Java. Inside this folder should be the folder: jre1.8.0_291, which itself should contain bin, lib, and legal folders, and some miscellaneous files (mostly .txt and .html). You can now follow the instructions to download and install Python (first) and then the Eclipse IDE.
🌐
Py4j
py4j.org
Welcome to Py4J — Py4J
Py4J enables Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine. Methods are called as if the Java objects resided in the Python interpreter and Java collections can be accessed through standard Python collection methods.
🌐
GraalVM
graalvm.org › python
GraalPy
Use Python packages directly in Java, Kotlin, or Scala
🌐
PyPI
pypi.org › project › import-java
import-java
April 30, 2018 - JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Reddit
reddit.com › r/usefulscripts › python script to download latest jre/jdk, then update local repository and wpkg packages
r/usefulscripts on Reddit: Python script to download latest JRE/JDK, then update local repository and WPKG packages
August 1, 2016 -

Extracting MSI files from the Java install prompted me to work up a method to keep Java updates in our WPKG share current. So here it is. Probably not the best Python, but it's functional (Python 2, should be adaptable to Python 3 easily). If you use a different deployment method (other than WPKG), you'll obviously need to adjust update_java_packages accordingly.

Features

  • Checks for latest Java 8 version from Javascript embedded in https://java.com/en/download/installed8.jsp

  • Stores JRE and JDK license acceptance in cookie before downloading. Of course you've agreed to it in the past.

  • Downloads latest JRE and JDK, runs installers long enough to copy extracted MSI and CAB files to destination folder.

  • Updates WPKG package files with new update numbers.

  • Records latest update downloaded, so the script can exit quickly if there's no new updates.

Scripts and support files stored in a single folder:

Win32 build of wget.exe

Most likely downloaded from https://eternallybored.org/misc/wget/.

update-java.py

#!/usr/bin/env python
from string import Template
from datetime import datetime, timedelta
import subprocess
import os
import glob
import shutil
import time

def unix_time(dt):
    epoch = datetime.utcfromtimestamp(0)
    return int((dt - epoch).total_seconds())

def make_cookies(cookies):
    cookieTemplate = Template('.${domain}\t${allmachines}\t${path}\t${secure}\t${expiration}\t${name}\t${value}\n')
    tomorrow = unix_time(datetime.now() + timedelta(days=1))
    d = dict(
        domain = 'oracle.com',
        allmachines = 'TRUE',
        path = '/',
        secure = 'FALSE',
        expiration = tomorrow,
        name = 'oraclelicense',
        value = 'accept-securebackup-cookie'
    )
    cookieString = cookieTemplate.safe_substitute(d)
    with open(cookies,'w') as f:
        f.write(cookieString)

def find_latest_update(version):
    versionUrl = Template("http://java.com/en/download/installed${version}.jsp")
    url = versionUrl.safe_substitute(version=version)
    output = subprocess.check_output(["wget", "-qO-", url])
    tagLine = Template("latest${version}Version").safe_substitute(version=version)
    for line in output.split('\n'):
        if tagLine in line:
            #print line
            (_, versionString, _) = line.split("'")
            # print versionString # 1.8.0_101
            (_, update) = versionString.split("_")
            # print update # 101
            return int(update)

def download_java(kinds, version, update, cookies):
    site = "http://download.oracle.com/otn-pub/java/jdk"
    b = 13 # not sure how often this changes
    archList = ["windows-x64", "windows-i586"]
    urlTemplate = Template("${site}/${version}u${update}-b${b}/${package}-${version}u${update}-${arch}.exe")
    for arch in archList:
        for package in kinds:
            d = dict(
                site = site,
                package = package,
                version = version,
                update = update,
                b = b,
                arch = arch
            )
            url = urlTemplate.safe_substitute(d)
            print "Downloading %s" % (url)
            cookieFlag = "--load-cookies=%s" % (cookies)
            subprocess.call(["wget", "-q", cookieFlag, url],
                            cwd = os.getcwd())

def copy_java_contents(kinds, version, update, msiDestination):
    # For each executable with correct version and update
    patternTemplate=Template("${kind}-${version}u${update}-windows-*.exe")
    for kind in kinds:
        d = dict(
            kind = kind,
            version = version,
            update = update
        )
        pattern = patternTemplate.safe_substitute(d)
        olddir = os.getcwd()
        for file in glob.glob(pattern):
            print file
            # - Make a directory in wpkg/software
            (_, _, _, archexe) = file.split("-")
            if archexe=="i586.exe":
                arch = "x86"
            elif archexe=="x64.exe":
                arch = "x64"
            path = msiDestination + (r'\%s\%d\%d-%s '[:-1] % (kind,
                                                              version,
                                                              update,
                                                              arch))
            print "Will makedirs(%s) if needed" % (path)
            if not os.path.isdir(path):
                os.makedirs(path, mode = 0755)
            # - Run the executable to extract contents to temp
            print "Starting %s" % (file)
            proc = subprocess.Popen([file], shell=False)
            print "Started %s as %s" % (file, proc)
            # - Copy contents to wpkg directory
            extract_parent = os.path.join(os.environ['USERPROFILE'], 'Appdata',
                                          'LocalLow', 'Oracle', 'Java')
            print "Chccking for extract parent directory %s..." % (extract_parent),
            while not os.path.isdir(extract_parent):
                time.sleep(1)
            os.chdir(extract_parent)
            print "done."
            if arch=="x64":
                tempFolder = "%s1.%d.0_%d_%s" % (kind, version, update, arch)
            else:
                tempFolder = "%s1.%d.0_%d" % (kind, version, update)
            print "Checking for extract directory...",
            while not os.path.isdir(tempFolder):
                time.sleep(1)
            os.chdir(tempFolder)
            print "done."
            print "Sleeping for 10 seconds...",
            time.sleep(10)
            print "done."
            # - Kill the executable
            subprocess.call(['taskkill', '/F', '/T', '/PID', str(proc.pid)])
            print "Copying files...",
            for f in glob.glob("*.msi"):
                shutil.copy(f,path)
            for f in glob.glob("*.cab"):
                shutil.copy(f,path)
            print "done."
            os.chdir('..')
            # - Remove contents from temp
            shutil.rmtree(tempFolder)
            os.chdir(olddir)

def update_java_packages(kinds, version, update, wpkgRoot, branches):
    for kind in kinds:
        for branch in branches:
            sourceXML = "%s-%d.xml" % (kind, version)
            with open(sourceXML) as templateXML:
                lines=templateXML.readlines()
            template = Template( ''.join(lines) )
            d=dict(update=update)
            targetXML = os.path.join(wpkgRoot,branch,'packages',sourceXML)
            with open(targetXML,'w') as packageXML:
                packageXML.writelines(template.safe_substitute(d))

def check_local_update(msiDestination, version):
    localfile = os.path.join(msiDestination, 'jdk', str(version),
                             'localVersion.txt')

    try:
        with open(localfile, 'r') as f:
            lines = f.readlines()
            update = int(lines[0])
    except IOError:
        update = 0
    return int(update)

def write_local_update(msiDestination, version, update):
    localVersionFile = os.path.join(msiDestination, 'jdk', str(version),
                                    'localVersion.txt')
    with open(localVersionFile, 'w') as f:
        f.write(str(update))

if __name__ == "__main__":
    version = 8
    cookies = 'cookies.txt'
    kinds = ["jdk", "jre"]
    #wpkgRoot = r'\\some.server.fqdn\wpkg '[:-1]
    wpkgRoot = r'c:\users\someuser\desktop\wpkg-tmp '[:-1]
    msiDestination = wpkgRoot+r'\software '[:-1]
    branches = [ 'dev', 'stable' ]

    print "Checking for latest update to Java %d" % (version)
    update = find_latest_update(version = version)
    print "It's update %s" % (update)
    localUpdate = check_local_update(msiDestination = msiDestination,
                                     version = version)
    if localUpdate < update:
        print "Local copy (%d) is out of date." % (localUpdate)
        print "Making cookies"
        make_cookies(cookies)
        download_java(kinds = kinds,
                      version = version,
                      update = update,
                      cookies = cookies)
        copy_java_contents(kinds = kinds,
                           version = version,
                           update = update,
                           msiDestination = msiDestination)
        update_java_packages(kinds = kinds,
                             version = version,
                             update = update,
                             wpkgRoot = wpkgRoot,
                             branches = branches)
        write_local_update(msiDestination = msiDestination,
                           version = version, update = update)
    else:
        print "Local copy (%d) is current." % (localUpdate)

jdk-8.xml

<!--
Automatically generated from update-java.py and software\jdk\jdk-8.xml template file.

Do not edit packages\jdk-8.xml manually.
-->
<!-- From http://wpkg.org/Java -->
<!-- See jre-6.xml for instructions -->

<packages>
  <package id='jdk-8' name='Java Development Kit 8' priority='548' reboot='postponed' revision='%update%'>
    <variable name='version' value='8' />
    <variable name='update' value='${update}' />

    <variable name='uninstall_name' value='Java SE Development Kit %version% Update %update% (64-bit)' architecture='x64' />
    <variable name='uninstall_name' value='Java SE Development Kit %version% Update %update%' architecture='x86' />
    <check condition='exists' path='%uninstall_name%' type='uninstall' />
    <variable architecture="x64" name="source" value="%SOFTWARE%\jdk\8\%update%-x64" />
    <variable architecture="x86" name="source" value="%SOFTWARE%\jdk\8\%update%-x86" />
    
    <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
      <exit code='0' />
      <exit code='1' />
      <exit code='128' />
    </install>
    <install cmd='msiexec /qn /i "%source%\jdk1.%version%.0_%update%.msi" JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No WEB_JAVA=1 INSTALLDIR="%PROGRAMFILES%\Java\JDK\"' />
    <upgrade include='install' />
    <remove cmd='msiexec /qn /x{64A3A4F4-B792-11D6-A78A-00B0D01%version%0%update%0}'>
      <exit code='1605' />
    </remove>
  </package>
</packages>

jre-8.xml

<!--
Automatically generated from update-java.py and software\jdk\jre-8.xml template file.

Do not edit packages\jre-8.xml manually.
-->
<!-- From http://wpkg.org/Java -->
<!-- See jre-6.xml for instructions -->

<packages>
  <package id='jre-8' name='Java Runtime Environment 8' priority='879' reboot='postponed' revision='%update%'>
    <variable name='version' value='8' />
    <variable name='update' value='${update}' />

    <variable name='uninstall_name' value='Java %version% Update %update%'/>
    <check condition='exists' path='%uninstall_name%' type='uninstall' />
    <variable name="source" value="%SOFTWARE%\jre\8\%update%-x86" />
    <variable architecture="x64" name="dest" value="%PROGRAMFILES(x86)%\Java\JDK" />
    <variable architecture="x86" name="dest" value="%PROGRAMFILES%\Java\JDK" />
    <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
      <exit code='0' />
      <exit code='1' />
      <exit code='128' />
    </install>
    <install cmd='msiexec /qn /i "%source%\jre1.%version%.0_%update%.msi" JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No WEB_JAVA=1 INSTALLDIR="%DEST%"' />
    <upgrade include='install' />
    <remove cmd='msiexec /qn /x{26A24AE4-039D-4CA4-87B4-2F8321%version%0%update%F0}'>
      <exit code='1605' />
    </remove>
  </package>
  <package id='jre-8-x64' name='Java Runtime Environment 8 (64-bit)' priority='878' reboot='postponed' revision='%update%'>
    <variable name='version' value='8' />
    <variable name='update' value='${update}' />

    <variable name='uninstall_name' value='Java %version% Update %update% (64-bit)' architecture='x64' />
    <check condition='exists' path='%uninstall_name%' type='uninstall' />
    <variable architecture="x64" name="source" value="%SOFTWARE%\jre\8\%update%-x64" />
    <variable architecture="x64" name="dest" value="%PROGRAMFILES%\Java\JDK" />
    
    <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
      <exit code='0' />
      <exit code='1' />
      <exit code='128' />
    </install>
    <install cmd='msiexec /qn /i "%source%\jre1.%version%.0_%update%.msi" JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No WEB_JAVA=1 INSTALLDIR="%DEST%"' />
    <upgrade include='install' />
    <remove cmd='msiexec /qn /X{26A24AE4-039D-4CA4-87B4-2F8641%version%0%update%F0}'>
      <exit code='1605' />
    </remove>
  </package>
</packages>

Usage:

From a command prompt in the folder containing the support files:

C:\path\to\folder>update-java.py
Checking for latest update to Java 8
It's update 101
Local copy (0) is out of date.
Making cookies
Downloading http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-windows-x64.exe
...
Chccking for extract parent directory C:\Users\someuser\Appdata\LocalLow\Oracle\Java... done.
Checking for extract directory... done.
Sleeping for 10 seconds... done.
SUCCESS: The process with PID 4144 (child process of PID 2664) has been terminated.
SUCCESS: The process with PID 2664 (child process of PID 2240) has been terminated.
Copying files... done.

C:\path\to\folder>update-java.py
Checking for latest update to Java 8
It's update 101
🌐
Coursera
coursera.org › browse › computer science › software development
Introduction to Programming with Python and Java | Coursera
Understand Java inheritance and apply techniques for parsing text in files, using advanced data structures to store information, and debugging code ... This Specialization starts out by teaching basic concepts in Python and ramps up to more complex subjects such as object-oriented programming and data structures in Java.
Rating: 4.5 ​ - ​ 1.9K votes
🌐
Runestone Academy
runestone.academy › ns › books › published › java4python › index.html
Welcome to Java for Python Programmers — Java for Python Programmers
Java for Python Programmers · Preface · Introduction · Why Learn another programming Language? Lets look at a Java Program · Java Data Types · Conditionals · Loops and Iteration · Defining Classes in Java · Naming Conventions · Common Mistakes · Java Documentation ·
🌐
O'Reilly
oreilly.com › library › view › python-programming-with › 0201616165 › 0201616165_app01lev1sec1.html
Installing Java Runtime - Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython [Book]
Even though I use the J2SE, I should say that Microsoft's free Java Virtual Machine (JVM) has some features that make it a good alternative with Windows. In particular, it streamlines the installation of Java packages and allows integration with ActiveX and Windows API via JDirect. Visit Microsoft's Web site for downloading instructions.
🌐
CodeConvert AI
codeconvert.ai › python-to-java-converter
Free Python to Java Converter — AI Code Translation | CodeConvert AI
Instantly convert Python to Java code with AI. Free, fast, and accurate code translation — 60+ languages supported, no signup required.