SoFunction
Updated on 2024-10-29

An easy way to package Python code as jar software

py Write fast.
But the java ecosystem is wide
For example, big data, py, while good, doesn't utilize the entire ecosystem of java code.

Scala is good, but after all, there are libraries that you have to write yourself.
It's easy, but it's a pain in the ass to check the documentation.

So, here's the problem.
The easiest way to do this is to package the py in a jar.

So, here's the problem. Py packaged as java is a pain in the ass, and the official docs don't make sense.

Answer. We have it.
Wrote package /yishenggudou/jythontools
Get this thing going.

timger-mac:test timger$ python ../jytool/  main 

timger-mac:test timger$ java -jar  
*sys-package-mgr*: processing modified jar, '/Users/timger/GitHub/jythontools/jytool/test/'
hello jython
timger-mac:test timger$ 

The overall code is as follows

timger-mac:test timger$ java -jar  a a s s s
hello jython
['a', 'a', 's', 's', 's']
timger-mac:test timger$ cat 
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2011 timger
#  +Author timger
#  +Gtalk&Email yishenggudou@
#  +Msn yishenggudou@
#  +Weibo @timger /zhanghaibo
#  +twitter @yishenggudou /yishenggudou
#  Licensed under the MIT License, Version 2.0 (the "License");
__author__ = 'timger'
import sys


def main():
  print "hello jython"
  print