2 Mar 12:11
Import error: jar and commapi(rxtxcomm)
pl <pl78 <at> katamail.com>
2008-03-02 11:11:11 GMT
2008-03-02 11:11:11 GMT
Hi, i have this problem:
Directory's structure of my application:
----myapplication.jar
--------Lib/
------------scan.py
------------string.py
------------othermodules.py
-------org.python.util (extract of jython.jar standalone)
-------lib-ext/
------------RXTXComm.jar (or commapi.jar)
------------other.jar
the Manifest file of myapplication.jar
Main-Class: org.python.util.jython
Class-Path: ../lib-ext/RXTXComm.jar ../lib-ext/other.jar
when i run this command: java -jar myapplication.jar scan.py
receive this error:
Traceback (innermost last):
File "<console>", line 1, in ?
File "/home/maverick/jythosbsl4.jar/Lib/scan$py.class", line 10, in ?
File "/home/maverick/jythosbsl4.jar/Lib/serial/__init__$py.class", line 17, in ?
File "/home/maverick/jythosbsl4.jar/Lib/serial/serialjava$py.class", line 8, in ?
ImportError: no module named gnu
gnu is a directory in the RXTXComm.jar package (gnu.io).
Manifest file of this package is empy.
This error is returned also when i copy the RXTXComm.jar (commapi.jar) in the java/lib/ext directory.
Other:
>>> from java.lang import System
>>> System.getProperty("java.class.path")
'/usr/lib/jvm/java-6-sun-1.6.0.03/lib:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/ext'
>>> import sys
>>> sys.path
['', '/home/maverick/myapplication.jar/Lib', '/home/maverick/myapplication.jar/Lib', '__classpath__']
furthermore if i extarct RXTXComm.jar and manually i copy directory in the myapplication.jar and add __init__.py
---myapplication.jar
--------Lib/
------------scan.py
------------string.py
------------othermodules.py
-------org.python.util (extract of jython.jar standalone)
-------gnu/
---------------__init__.py
---------------io/
---------------------__init__.py
---------------------CommPortIdentifier.class
---------------------Otherclass.class
I receive this error:
Errore: 'module' object has no attribute 'CommPortIdentifier'
//scan.py
import serial, sys
def scan():
"""scan for available ports. return a list of tuples (num, name)"""
available = []
for i in range(256):
try:
s = serial.Serial(i)
available.append( (i, s.portstr))
s.close() #explicit close 'cause of delayed GC in java
except Exception:
pass
return available
if __name__=='__main__':
print "PATH: ", sys.path
print "Found ports:"
for n,s in scan():
print "(%d) %s" % (n,s)
serialjava.py
import sys, os, string, gnu.io
.............
enum = gnu.io.CommPortIdentifier.getPortIdentifiers() //return error
Attention: from Eclipse IDE this application runs very well
Thanks
PL
Directory's structure of my application:
----myapplication.jar
--------Lib/
------------scan.py
------------string.py
------------othermodules.py
-------org.python.util (extract of jython.jar standalone)
-------lib-ext/
------------RXTXComm.jar (or commapi.jar)
------------other.jar
the Manifest file of myapplication.jar
Main-Class: org.python.util.jython
Class-Path: ../lib-ext/RXTXComm.jar ../lib-ext/other.jar
when i run this command: java -jar myapplication.jar scan.py
receive this error:
Traceback (innermost last):
File "<console>", line 1, in ?
File "/home/maverick/jythosbsl4.jar/Lib/scan$py.class", line 10, in ?
File "/home/maverick/jythosbsl4.jar/Lib/serial/__init__$py.class", line 17, in ?
File "/home/maverick/jythosbsl4.jar/Lib/serial/serialjava$py.class", line 8, in ?
ImportError: no module named gnu
gnu is a directory in the RXTXComm.jar package (gnu.io).
Manifest file of this package is empy.
This error is returned also when i copy the RXTXComm.jar (commapi.jar) in the java/lib/ext directory.
Other:
>>> from java.lang import System
>>> System.getProperty("java.class.path")
'/usr/lib/jvm/java-6-sun-1.6.0.03/lib:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/ext'
>>> import sys
>>> sys.path
['', '/home/maverick/myapplication.jar/Lib', '/home/maverick/myapplication.jar/Lib', '__classpath__']
furthermore if i extarct RXTXComm.jar and manually i copy directory in the myapplication.jar and add __init__.py
---myapplication.jar
--------Lib/
------------scan.py
------------string.py
------------othermodules.py
-------org.python.util (extract of jython.jar standalone)
-------gnu/
---------------__init__.py
---------------io/
---------------------__init__.py
---------------------CommPortIdentifier.class
---------------------Otherclass.class
I receive this error:
Errore: 'module' object has no attribute 'CommPortIdentifier'
//scan.py
import serial, sys
def scan():
"""scan for available ports. return a list of tuples (num, name)"""
available = []
for i in range(256):
try:
s = serial.Serial(i)
available.append( (i, s.portstr))
s.close() #explicit close 'cause of delayed GC in java
except Exception:
pass
return available
if __name__=='__main__':
print "PATH: ", sys.path
print "Found ports:"
for n,s in scan():
print "(%d) %s" % (n,s)
serialjava.py
import sys, os, string, gnu.io
.............
enum = gnu.io.CommPortIdentifier.getPortIdentifiers() //return error
Attention: from Eclipse IDE this application runs very well
Thanks
PL
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ Jython-users mailing list Jython-users <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jython-users
I only occasionally use Jython, when it seems most suitable to the
project at hand, but nevertheless it's great to see it getting this sort
of backing.
RSS Feed