pyjnius custom classpath exception
See original GitHub issueI am using the latest pyjnius from pip: 1.0.2
I have set up my CLASSPATH in .bash_profile (Ubuntu 12.04 LTS 64 bit
). Then, did source ~/.bash_profile
.
echo $CLASSPATH /home/2010/giasu/dev/opinion/opinion/java/stanfordCorenlp/bin:/home/2010/giasu/dev/opinion/opinion/java/opinion/bin:/home/2010/giasu/dev/opinion/external/java/libs/*
Then I opened an IPython session:
IPython 2.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import os
In [2]: print os.environ['CLASSPATH']
/home/2010/giasu/dev/opinion/opinion/java/stanfordCorenlp/bin:/home/2010/giasu/dev/opinion/opinion/java/opinion/bin:/home/2010/giasu/dev/opinion/external/java/libs/*
Now, I tried to access one class from from the package: opinion.nlp
In [3]: from jnius import autoclass
In [4]: autoClass = autoclass('opinion.nlp.SentenceDetector')
---------------------------------------------------------------------------
JavaException Traceback (most recent call last)
<ipython-input-4-1c9e6bf51096> in <module>()
----> 1 autoClass = autoclass('opinion.nlp.SentenceDetector')
/diskless/aspect-5/giasu/virtualenvs/opinion/lib/python2.7/site-packages/jnius/reflect.pyc in autoclass(clsname)
104
105 #c = Class.forName(clsname)
--> 106 c = find_javaclass(clsname)
107 if c is None:
108 raise Exception('Java class {0} not found'.format(c))
/diskless/aspect-5/giasu/virtualenvs/opinion/lib/python2.7/site-packages/jnius/jnius.so in jnius.find_javaclass (jnius/jnius.c:7192)()
JavaException: Class not found 'opinion/nlp/SentenceDetector'
There is SentenceDetector class in: /home/2010/giasu/dev/opinion/opinion/java/opinion/bin:
[giasu][aspect-5][~] ls /home/2010/giasu/dev/opinion/opinion/java/opinion/bin/opinion/nlp/
SentenceDetector.class
I can access the jdk libraries:
In [5]: from jnius import autoclass
In [6]: autoClass = autoclass('java.util.ArrayList')
No exception.
This is my JDK:
[giasu][aspect-5][~] java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1~0.12.04.2)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
This is how I installed pyjnius:
pip install jnius
Downloading/unpacking jnius
Downloading jnius-1.0.2.tar.gz
Running setup.py (path:/diskless/aspect-5/giasu/virtualenvs/opinion/build/jnius/setup.py) egg_info for package jnius
Requirement already satisfied (use --upgrade to upgrade): cython in /diskless/aspect-5/giasu/virtualenvs/opinion/lib/python2.7/site-packages (from jnius)
Installing collected packages: jnius
Running setup.py install for jnius
cythoning jnius/jnius.pyx to jnius/jnius.c
building 'jnius' extension
gcc -pthread -fPIC -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/jvm/java-7-openjdk-amd64/include -I/usr/lib/jvm/java-7-openjdk-amd64/include/linux -I/diskless/aspect-5/giasu/packages/python-as-2.7.6/include/python2.7 -c jnius/jnius.c -o build/temp.linux-x86_64-2.7/jnius/jnius.o
gcc -pthread -shared build/temp.linux-x86_64-2.7/jnius/jnius.o -L/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server -ljvm -o build/lib.linux-x86_64-2.7/jnius/jnius.so -Wl,-rpath /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server
Successfully installed jnius
Cleaning up...
This is my OS:
[giasu][aspect-5][~] uname -a
Linux aspect-5 3.8.0-35-generic #52~precise1-Ubuntu SMP Thu Jan 30 17:24:40 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
This is my Python installation:
[giasu][aspect-5][~] python
ActivePython 2.7.6.9 (ActiveState Software Inc.) based on
Python 2.7.6 (default, Feb 27 2014, 14:04:52)
[GCC 4.0.2 20051125 (Red Hat 4.0.2-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Note that the Python distribution is from ActivePython. I installed Python 2.7.6.9 64 bit
as non-root from here: http://downloads.activestate.com/ActivePython/releases/2.7.6.9/ActivePython-2.7.6.9-linux-x86_64.tar.gz
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Version 1.0.2 doesn’t support setting the classpath. You need to use 1.0.3 or a version from git.
That worked. Thanks for your help, James.