• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

将Python代码打包为jar软件的简单方法

python 搞代码 4年前 (2022-01-09) 34次浏览 已收录 0个评论

py 写东西快
但是java 生态广
比如大数据 py 虽然好 但是利用不到java的整个的生态的代码

scala 虽然也好但是毕竟 有些库 需要自己写的多
虽然也很简单 ,但是查文档也很麻烦

那么 问题来了
最简单的的方式就是直接把py 打包 jar

那么 问题又来了 py 打包成java 挺麻烦的 官方文档看不懂

答案 有了
写了个 包 https://github.com/yi本文来源[email protected]搞@^&代*@码)网9shenggudou/jythontools
搞这个事情

timger-mac:test timger$ python ../jytool/jytoollib.py hellojython.py main timger-mac:test timger$ java -jar output.jython.jar *sys-package-mgr*: processing modified jar, '/Users/timger/GitHub/jythontools/jytool/test/output.jython.jar'hello jythontimger-mac:test timger$ 

整体代码如下

timger-mac:test timger$ java -jar output.jython.jar a a s s shello jython['a', 'a', 's', 's', 's']timger-mac:test timger$ cat hellojython.py#!/usr/bin/env python# -*- coding: utf-8 -*-## Copyright 2011 timger#  +Author timger#  +Gtalk&Email [email protected]#  +Msn [email protected]#  +Weibo @timger http://t.sina.com/zhanghaibo#  +twitter @yishenggudou http://twitter.com/yishenggudou#  Licensed under the MIT License, Version 2.0 (the "License");__author__ = 'timger'import sysdef main():  print "hello jython"  print sys.argv

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:将Python代码打包为jar软件的简单方法
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址