Using a java library from python

前端 未结 6 1361
日久生厌
日久生厌 2020-12-02 07:38

I have a python app and java app. The python app generates input for the java app and invokes it on the command line.

I\'m sure there must be a more elegant solution

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 08:19

    Give JCC a try http://pypi.python.org/pypi/JCC/2.1

    JCC is a code generator for calling Java directly from CPython. It supports CPython 2.3+, several JREs (Sun JDK 1.4+, Apple JRE 1.4+, and OpenJDK 1.7) on OS X, Linux, Solaris, and Windows. It's produced by the Open Source Application Foundation (OSAF, the people making Chandler) and is released under an Apache-style license.

    From the package description:

    JCC is a C++ code generator for producing the glue code necessary to call into Java classes from CPython via Java's Native Invocation Interface (JNI).

    JCC generates C++ wrapper classes that hide all the gory details of JNI access as well Java memory and object reference management.

    JCC generates CPython types that make these C++ classes accessible from a Python interpreter. JCC attempts to make these Python types pythonic by detecting iterators and property accessors. Iterators and mappings may also be declared to JCC.

提交回复
热议问题