Skip to content

Jython support in JBang #1909

Answered by wfouche
wfouche asked this question in Ideas
Jan 23, 2025 · 4 comments · 10 replies
Discussion options

You must be logged in to vote

A simpler and pure JBang solution is possible using my (by now) better understanding of the Jython source code. I had a look at the Jython Java source code, and discovered a simply way of bootstrapping Jython via a Jbang Java script:

Jython.java

///usr/bin/env jbang "$0" "$@" ; exit $?

//DEPS com.google.code.gson:gson:2.11.0
//DEPS org.hdrhistogram:HdrHistogram:2.2.2

//DEPS org.python:jython-standalone:2.7.4

import org.python.util.jython;

public class Jython {
    public static void main(String... args) {
        jython.main(args);
    }
}

Any jython script can then be run with command:

$ jbang run Jython.java <script.py> <param1> <param2> ...

Replies: 4 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@wfouche
Comment options

@maxandersen
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@maxandersen
Comment options

Comment options

You must be logged in to vote
7 replies
@quintesse
Comment options

@quintesse
Comment options

@wfouche
Comment options

@wfouche
Comment options

Answer selected by wfouche
@quintesse
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants