Title: [Windows] Include a native command line launcher for Windows
Type: rfe Severity: normal
Components: Core Versions: Jython 2.7
Status: pending Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: fwierzbicki, geoffbache, hpk, otmarhumbel, pekka.klarck, pjenvey, zyasoft
Priority: urgent Keywords:

Created on 2009-10-21.20:05:20 by pjenvey, last changed 2015-02-22.17:36:38 by pekka.klarck.

msg5251 (view) Author: Philip Jenvey (pjenvey) Date: 2009-10-21.20:05:19
The most full proof way of solving the .bat file launcher 
incompatibilities (inconsistent arg handling: #1356, #1371, setuptools 
script launcher doesn't work on Windows: #1112) on Windows is to include 
a native .exe launcher

Groovy has had one for a while now:

But JRuby just recently created their own for their 1.4 release:

Since our .sh/.bat launchers are based off JRuby's, adopting their .exe 
launcher should probably be pretty straightforward
msg5552 (view) Author: Philip Jenvey (pjenvey) Date: 2010-02-25.00:29:04
The JRuby launcher now supports unix platforms
msg5704 (view) Author: Pekka Klärck (pekka.klarck) Date: 2010-04-14.14:57:45
I've noticed many problems with jython.bat distributed with 2.5.1 lately (#1491, #1599). It would be great to replace jython.bat with jython.exe.
msg5740 (view) Author: holger krekel (hpk) Date: 2010-04-23.08:58:20
a note to support the need for resolving this issue: While py.test works with Jython on Unix it does not do so on Windows because of the missing launcher-support.  Effectively I'd like to be able to use virtualenv and install packages including cmdline tools on Jython/XP.
msg6273 (view) Author: Geoff Bache (geoffbache) Date: 2010-12-08.10:16:50
I guess I'm the third test tool author signing in here who's just run into various trouble trying to make things work with Jython on Windows due to this issue. Would really appreciate a fix here.
msg9372 (view) Author: Jim Baker (zyasoft) Date: 2015-01-09.03:54:18
Would be nice to add for RC1
msg9515 (view) Author: Jim Baker (zyasoft) Date: 2015-02-12.00:24:29
Adapting jruby-launcher ( and the corresponding gem ( makes sense, but Thomas Enebo tells me on #jython that it's a pain to maintain.

For now, I'm going to explore use py2exe to generate a jython.exe, which then launches the actual jython.jar. Yes, this is adding a subset of CPython to the Jython distribution, but it seems to make sense, and I don't have to modify any C++ code to get this launcher working. I get to write Python instead :)
msg9522 (view) Author: Jim Baker (zyasoft) Date: 2015-02-13.20:59:43
Blocker for RC1
msg9528 (view) Author: Jim Baker (zyasoft) Date: 2015-02-18.07:50:37
Initial implementation of supporting Python script as of

Next step is to create jython.exe using py2exe
msg9529 (view) Author: Pekka Klärck (pekka.klarck) Date: 2015-02-18.08:39:08
I hope `` could replace also `jython` shell script to make start-up consistent on different platforms. Having only one start-up script would also mean less maintenance work.

It would be nice for `jython(.py)` to support also CPython 2.6. The main motivation would be to ease using Jython 2.7 on RHEL 6 (still pretty widely used and supported until 2020) which only has CPython 2.6 by default. It seems that it would mainly require vendoring backports of argparse and OrderedDict (both available on PyPI) and replacing `python2.7` with `python` on the shebang line.

If it's not too much work, it would also be nice to support CPython 3.x. That would also avoid problems using `python` on the shebang with Arch Linux where `python` runs CPython 3. 

If there are no objections, I can take a look at these enhancements myself.
msg9537 (view) Author: Jim Baker (zyasoft) Date: 2015-02-22.06:20:58
Fixed as of
msg9543 (view) Author: Jim Baker (zyasoft) Date: 2015-02-22.14:50:41
Please note that the current construction of jython.exe is an overkill, given that it's about 3.6MB between jython.exe and the bundled python27.dll. Writing a launcher in C would definitely be on the order of a few kilobytes. But it's also completely necessary for the moment.

jython.exe is created by using PyInstaller (, using the simplest invocation after installing with pip pyinstaller, in src\shell:


(or the install directory of CPython, but with Windows, I just stick to the defaults)

This creates a build directory, from which I extracted jython.exe and python27.dll and also placed in src\shell. Someone should write a build script! ;) Note that we cannot bundle PyInstaller itself since it's GPL, but we can freely redistribute its output, much like gcc.

So if you look at the src/shell/ (-> bin/, you will notice a very simple Python script. It would be simple in principle to translate this into C, and shave off the 3.6MB it currently costs. But I am not a Windows developer, so this needs to be done by someone who is interested in dealing with all the details, including unicode args on the command line, along with supporting cygwin.

Of course there's no reason for jython.exe and python27.dll to be installed for non Windows systems, so that can be fixed in the Jython installer.

One more thing: having a Python launcher means we can readily do things like prewarmed/recycled VMs, but with security - at least on systems supporting domain sockets (not certain if named pipes on Windows work sufficiently). But that's a future feature, for 2.7.1 or later.
msg9545 (view) Author: Pekka Klärck (pekka.klarck) Date: 2015-02-22.17:36:38
I wouldn't be too worried with 3.6MB. Increased maintenance cost would, in my opinion, be a much bigger problem.

For writing a build script I'd consider Or Maven if the plan is to fully switch to it.
Date User Action Args
2015-02-22 17:36:38pekka.klarcksetmessages: + msg9545
2015-02-22 14:50:41zyasoftsetmessages: + msg9543
2015-02-22 06:20:58zyasoftsetstatus: open -> pending
resolution: remind -> fixed
messages: + msg9537
2015-02-18 08:39:09pekka.klarcksetmessages: + msg9529
2015-02-18 07:50:37zyasoftsetmessages: + msg9528
2015-02-13 20:59:43zyasoftsetpriority: high -> urgent
messages: + msg9522
2015-02-12 00:24:30zyasoftsetassignee: otmarhumbel -> zyasoft
messages: + msg9515
2015-01-09 03:54:18zyasoftsetpriority: normal -> high
nosy: + zyasoft
messages: + msg9372
2014-05-22 00:03:14zyasoftsetresolution: remind
2013-02-26 17:23:40fwierzbickisetversions: + Jython 2.7
2010-12-08 10:16:50geoffbachesetmessages: + msg6273
2010-12-08 10:15:15geoffbachesetnosy: + geoffbache
2010-05-02 17:55:15otmarhumbelsetassignee: otmarhumbel
nosy: + otmarhumbel
2010-04-23 08:58:21hpksetnosy: + hpk
messages: + msg5740
2010-04-14 14:57:45pekka.klarcksetnosy: + pekka.klarck
messages: + msg5704
2010-02-25 00:29:04pjenveysetmessages: + msg5552
2009-10-21 20:07:15fwierzbickisetnosy: + fwierzbicki
2009-10-21 20:05:20pjenveycreate