Back in 2005 I posted a message to this forum (https://sourceforge.net/forum/forum.php?thread_id=1391722&forum_id=379372) that was never answered. I haven't used JPype much in the intervening years, but now I'm trying to use it again and getting the same problem with JArray. Here's today's example:
>>> from jpype import *
>>> a = JArray(JByte)
>>> a
<class 'jpype._jarray.byte[]'>
>>> b = a(10)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\Lib\site-packages\jpype\_jarray.py", line 73, in _jarrayInit
_JavaArrayClass.__init__(self, _jpype.newArray(self.__class__.__javaclass__, sz))
TypeError: argument 1 must be PyCObject, not None
I'm using ActivePython 2.5.1.1. Am I not doing something right? Or could this be a problem with my version of Python?
Any help to get this working would be greatly appreciated. If I don't get a solution by Monday I may have to switch to Jython and access Java that way.
Thanks,
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Back in 2005 I posted a message to this forum (https://sourceforge.net/forum/forum.php?thread_id=1391722&forum_id=379372) that was never answered. I haven't used JPype much in the intervening years, but now I'm trying to use it again and getting the same problem with JArray. Here's today's example:
>>> from jpype import *
>>> a = JArray(JByte)
>>> a
<class 'jpype._jarray.byte[]'>
>>> b = a(10)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\Lib\site-packages\jpype\_jarray.py", line 73, in _jarrayInit
_JavaArrayClass.__init__(self, _jpype.newArray(self.__class__.__javaclass__, sz))
TypeError: argument 1 must be PyCObject, not None
I'm using ActivePython 2.5.1.1. Am I not doing something right? Or could this be a problem with my version of Python?
Any help to get this working would be greatly appreciated. If I don't get a solution by Monday I may have to switch to Jython and access Java that way.
Thanks,
Martin
Boy do I feel dumb now! I forgot to do
startJVM(r"C:\java\jdk1.6.0_01\jre\bin\client\jvm.dll", "-ea")
before doing the steps above. I do this in my code all the time, but I forgot to do it in the interactive Python session.
It would be a big improvement to JPype if it gave an error message like "Must call startJVM first" if any other method is attempted before doing this.