- Py4j - 내부적으로 Java Server 를 구동해서 연동하는 방식
- JPype - JVM 을 startup/shutdown 을 Python 에서 관리
- JCC - 2.X 버전만 지원
- PyJNIus - JVM 실행 파일로 실행
- JDK
- JAVA_HOME or JRE_HOME 환경변수 설정
- PATH 에 %JAVA_HOME%/jre/bin/server 경로 설정(jvm.dll 을 실행하기 위함)
- Cython
- Visual C++ Redistributable Package (only window)
https://www.microsoft.com/ko-kr/download/details.aspx?id=48159
이를 설치하지 않으면 PyJNIus 가 정상적으로 설치 되지 않을 뿐만 아니라 import 시 DLL 을 로딩할 수 없다는 오류가 발생
http://stackoverflow.com/questions/20970732/jnius-1-1-import-error
dll 로딩 오류가 발생시 dependency walker 를 통해 어떤 dll 이 실패하였는지 확인 할 수 있습니다.
- window 7(64bit)
- python 3.5.1
python setup.py install
|
WARNING: Not able to assign machine() = AMD64 to a cpu value! Using cpu = 'i386' instead! C:\dev\dev_env\virtualenv\django_uit\lib\site-packages\setuptools\dist.py:285: UserWarning: Normalizing '1.1-dev' to '1.1.dev0' normalized_version, running install running bdist_egg running egg_info writing jnius.egg-info\PKG-INFO writing requirements to jnius.egg-info\requires.txt writing top-level names to jnius.egg-info\top_level.txt writing dependency_links to jnius.egg-info\dependency_links.txt reading manifest file 'jnius.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching '*COPYING' writing manifest file 'jnius.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py running build_ext skipping 'jnius\jnius.c' Cython extension (up-to-date) creating build\bdist.win-amd64\egg creating build\bdist.win-amd64\egg\jnius copying build\lib.win-amd64-3.5\jnius\jnius.cp35-win_amd64.pyd -> build\bdist.win-amd64\egg\jnius copying build\lib.win-amd64-3.5\jnius\reflect.py -> build\bdist.win-amd64\egg\jnius copying build\lib.win-amd64-3.5\jnius\signatures.py -> build\bdist.win-amd64\egg\jnius copying build\lib.win-amd64-3.5\jnius\__init__.py -> build\bdist.win-amd64\egg\jnius copying build\lib.win-amd64-3.5\jnius_config.py -> build\bdist.win-amd64\egg byte-compiling build\bdist.win-amd64\egg\jnius\reflect.py to reflect.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\jnius\signatures.py to signatures.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\jnius\__init__.py to __init__.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\jnius_config.py to jnius_config.cpython-35.pyc creating stub loader for jnius\jnius.cp35-win_amd64.pyd byte-compiling build\bdist.win-amd64\egg\jnius\jnius.py to jnius.cpython-35.pyc creating build\bdist.win-amd64\egg\EGG-INFO copying jnius.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO copying jnius.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO copying jnius.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO copying jnius.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO copying jnius.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO writing build\bdist.win-amd64\egg\EGG-INFO\native_libs.txt zip_safe flag not set; analyzing archive contents... jnius.__pycache__.jnius.cpython-35: module references __file__ creating 'dist\jnius-1.1.dev0-py3.5-win-amd64.egg' and adding 'build\bdist.win-amd64\egg' to it removing 'build\bdist.win-amd64\egg' (and everything under it) Processing jnius-1.1.dev0-py3.5-win-amd64.egg removing 'c:\dev\dev_env\virtualenv\django_uit\lib\site-packages\jnius-1.1.dev0-py3.5-win-amd64.egg' (and everything under it) creating c:\dev\dev_env\virtualenv\django_uit\lib\site-packages\jnius-1.1.dev0-py3.5-win-amd64.egg Extracting jnius-1.1.dev0-py3.5-win-amd64.egg to c:\dev\dev_env\virtualenv\django_uit\lib\site-packages jnius 1.1.dev0 is already the active version in easy-install.pth
Installed c:\dev\dev_env\virtualenv\django_uit\lib\site-packages\jnius-1.1.dev0-py3.5-win-amd64.egg Processing dependencies for jnius==1.1.dev0 Searching for Cython==0.24.1 Best match: Cython 0.24.1 Adding Cython 0.24.1 to easy-install.pth file Installing cygdb-script.py script to C:\dev\dev_env\virtualenv\django_uit\Scripts Installing cygdb.exe script to C:\dev\dev_env\virtualenv\django_uit\Scripts Installing cythonize-script.py script to C:\dev\dev_env\virtualenv\django_uit\Scripts Installing cythonize.exe script to C:\dev\dev_env\virtualenv\django_uit\Scripts Installing cython-script.py script to C:\dev\dev_env\virtualenv\django_uit\Scripts Installing cython.exe script to C:\dev\dev_env\virtualenv\django_uit\Scripts
Using c:\dev\dev_env\virtualenv\django_uit\lib\site-packages Searching for six==1.10.0 Best match: six 1.10.0 Adding six 1.10.0 to easy-install.pth file
Using c:\dev\dev_env\virtualenv\django_uit\lib\site-packages Finished processing dependencies for jnius==1.1.dev0
|
from jnius import autoclass
autoclass(‘java.lang.System’).out.println(‘hello world’)
|
import jnius_config
jnius_config.add_options(‘-Xrs’, ‘-Xmx4096’)
jnius_config.set_classpath(‘.’, ‘{classpath 경로}’)
import jnius
|
from jnius import JavaClass, MetaJavaClass
class Stack(JavaClass):
__javaclass__ = ‘java/util/Stack'
__metaclass__ = MetaJavaClass
|
from jnius import autoclass
autoclass(‘java.lang.System’).out.println(‘hello world’)
|
- https://github.com/kivy/pyjnius
- https://www.microsoft.com/ko-kr/download/details.aspx?id=48159
- http://pyjnius.readthedocs.io/en/latest/installation.html
- http://stackoverflow.com/questions/20970732/jnius-1-1-import-error
- https://pyjnius.readthedocs.io/en/latest/api.html
'Programing > Python' 카테고리의 다른 글
Python + Jenkins 연동 (0) | 2016.08.26 |
---|---|
sqlparse 사용기 (0) | 2016.08.18 |
PEP8 이란? (0) | 2016.07.27 |
APScheduler 사용기 (0) | 2016.07.26 |
JPype 사용기 (0) | 2016.07.19 |