Installing Jython
Jython is distributed as an installer (a .zip or .tar.gz archive) that unpacks into a directory with the jython launcher script. A working Java (JDK or JRE) is required, because Jython runs on the JVM.
Prerequisites
- Java 8 or newer installed and on PATH (java -version should work).
- Platform: Linux, macOS, or Windows - the same archive works on all of them.
Download and Unpack
# example layout after unpacking jython-2.7.3
cd ~/downloads
unzip jython-2.7.3.zip
cd jython-2.7.3
The Launcher
# Unix/macOS:
./jython --version
# Windows:
jython.bat --version
# or, if you added the bin dir to PATH:
jython --version
# Jython 2.7.x on Java(TM) SE Runtime Environment ...
jython is a shell script (Unix) or batch file (Windows) that starts the JVM with Jython's classpath and runs the Python interpreter. jython.sh / jython.bat are the underlying launchers; jython is the convenience wrapper.
Adding to PATH
# ~/.bashrc or ~/.zshrc
export PATH="$HOME/downloads/jython-2.7.3:$PATH"
jython -c "import sys; print(sys.version)"
Running a Script
cat > hello.py <<'EOF'
print("Hello from Jython")
import java.lang
print(java.lang.System.getProperty("java.version"))
EOF
jython hello.py
Interactive Mode
jython
>>> import java.util
>>> java.util.Arrays.asList("a", "b")
>>> exit() # or Ctrl-D
Summary
Install Jython by unpacking the official archive, ensuring a JDK is on PATH, and using the jython launcher (./jython on Unix, jython.bat on Windows) to run scripts or the interactive interpreter. Add the bin directory to PATH for convenience and verify with jython --version and a small script that imports a java.* class.