Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Unable to use RXTX Java library [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
mikek
n00b
n00b


Joined: 28 Dec 2003
Posts: 8

PostPosted: Tue Dec 18, 2007 4:23 pm    Post subject: Unable to use RXTX Java library [solved] Reply with quote

I've got an application that requires the use of the RXTX library. I've got it installed against the sun jdk (version 1.6) and it appears like the compiler can't find it.

I've written a small test app that shows the errors:

Code:

mike@speedy ~/src $ cat test.java
import gnu.io.CommPort;
mike@speedy ~/src $ javac -verbose test.java
[parsing started test.java]
[parsing completed 33ms]
[search path for source files: .]
[search path for class files: /opt/sun-jdk-1.6.0.02/jre/lib/resources.jar,/opt/sun-jdk-1.6.0.02/jre/lib/rt.jar,/opt/sun-jdk-1.6.0.02/jre/lib/sunrsasign.jar,/opt/sun-jdk-1.6.0.02/jre/lib/jsse.jar,/opt/sun-jdk-1.6.0.02/jre/lib/jce.jar,/opt/sun-jdk-1.6.0.02/jre/lib/charsets.jar,/opt/sun-jdk-1.6.0.02/jre/classes,/opt/sun-jdk-1.6.0.02/jre/lib/ext/sunjce_provider.jar,/opt/sun-jdk-1.6.0.02/jre/lib/ext/sunpkcs11.jar,/opt/sun-jdk-1.6.0.02/jre/lib/ext/dnsns.jar,/opt/sun-jdk-1.6.0.02/jre/lib/ext/localedata.jar,.]
test.java:1: package gnu.io does not exist
import gnu.io.CommPort;
             ^
[total 474ms]
1 error


Looking at the jar file, it appears that everything is there

Code:

mike@speedy ~/src $ unzip -l /usr/share/rxtx-2/lib/RXTXcomm.jar
Archive:  /usr/share/rxtx-2/lib/RXTXcomm.jar
  Length     Date   Time    Name
 --------    ----   ----    ----
        0  12-17-07 14:31   META-INF/
       71  12-17-07 14:31   META-INF/MANIFEST.MF
        0  12-17-07 14:31   gnu/io/
     1453  12-17-07 14:31   gnu/io/CommPort.class


Is there something else I need to do after emerging RXTX to get java to know about it?

Thanks in advance for any help!
mike


Last edited by mikek on Tue Dec 18, 2007 7:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
alistair
Retired Dev
Retired Dev


Joined: 15 Jul 2005
Posts: 869

PostPosted: Tue Dec 18, 2007 6:45 pm    Post subject: Reply with quote

javac -classpath <path to dependencies separated by :> Test.java


or my favourite

javac -cp $(java-config -p rxtx-2) Test.java

[Edit]

Just because you have rxtx-2 installed does not mean that java can find it automatically.
_________________
______________
Help the gentoo-java project. Visit Gentoo Java Project

what good are admin powers if you don't abuse them for personal gain - mark_alec
Back to top
View user's profile Send private message
mikek
n00b
n00b


Joined: 28 Dec 2003
Posts: 8

PostPosted: Tue Dec 18, 2007 7:01 pm    Post subject: Unable to use RXTX Java library [solved] Reply with quote

alistair wrote:

javac -cp $(java-config -p rxtx-2) Test.java


Of course, that worked.


Quote:
Just because you have rxtx-2 installed does not mean that java can find it automatically.


Why is that? With all the java-config stuff, I'd have thought that emerging a java library would have updated the system settings such that it could be found? (I've obviously not had much experience with Java, much less how Gentoo is setup...apologies for the ignorant questions :)

Thanks again,
mike
Back to top
View user's profile Send private message
rscott13
n00b
n00b


Joined: 09 Jan 2008
Posts: 3

PostPosted: Wed Jan 09, 2008 5:27 am    Post subject: Issues with RXTX Reply with quote

I'm having difficulties with RXTX:

java -cp $(java-config -p rxtx-2) -jar analyzer.jar
Exception in thread "main" java.lang.NoClassDefFoundError: gnu/io/CommPortIdentifier
at org.sump.analyzer.Device.getPorts(Device.java:366)
at org.sump.analyzer.DeviceController.<init>(DeviceController.java:123)
at org.sump.analyzer.MainWindow.<init>(MainWindow.java:252)
at org.sump.analyzer.Loader.main(Loader.java:49)

This is after setting the CLASS_PATH and LD_LIBRARY_PATH variables:
export LD_ export CLASSPATH=.:/usr/share/rxtx-2/lib/RXTXcomm.jar
LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/rxtx-2

And I've emerged rxtx:

emerge -s rxtx
Searching...
[ Results for search key : rxtx ]
[ Applications found : 1 ]

* dev-java/rxtx
Latest version available: 2.1.7.2-r1
Latest version installed: 2.1.7.2-r1
Size of files: 1,314 kB
Homepage: http://rxtx.org/
Description: Native lib providing serial and parallel communication for Java
License: LGPL-2


Any hints? I'm trying to get an FPGA based logic analyzer to work again. (It did work on this system at one point...)

Thanks in advance!
Back to top
View user's profile Send private message
rscott13
n00b
n00b


Joined: 09 Jan 2008
Posts: 3

PostPosted: Wed Jan 09, 2008 4:37 pm    Post subject: Reply with quote

In case anyone else runs in to this, I hacked around the problem by physically coping the files into the right location.

First, make sure you know which version of java is in use:
java -version

java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Server VM (build 1.6.0_02-b05, mixed mode)

Go to the java ext lib:
cd /opt/sun-jre-bin-1.6.0.02/lib/ext

Copy the RXTXcomm.jar:
cp -av $(java-config -p rxtx-2) .
`/usr/share/rxtx-2/lib/RXTXcomm.jar' -> `./RXTXcomm.jar'

Now go to binary lib:
cd ../i386
cp -av $(java-config -i rxtx-2)/* .
`/usr/lib/rxtx-2/librxtxI2C-2.1-7.so' -> `./librxtxI2C-2.1-7.so'
`/usr/lib/rxtx-2/librxtxI2C.so' -> `./librxtxI2C.so'
`/usr/lib/rxtx-2/librxtxParallel-2.1-7.so' -> `./librxtxParallel-2.1-7.so'
`/usr/lib/rxtx-2/librxtxParallel.so' -> `./librxtxParallel.so'
`/usr/lib/rxtx-2/librxtxRaw-2.1-7.so' -> `./librxtxRaw-2.1-7.so'
`/usr/lib/rxtx-2/librxtxRaw.so' -> `./librxtxRaw.so'
`/usr/lib/rxtx-2/librxtxRS485-2.1-7.so' -> `./librxtxRS485-2.1-7.so'
`/usr/lib/rxtx-2/librxtxRS485.so' -> `./librxtxRS485.so'
`/usr/lib/rxtx-2/librxtxSerial-2.1-7.so' -> `./librxtxSerial-2.1-7.so'
`/usr/lib/rxtx-2/librxtxSerial.so' -> `./librxtxSerial.so'

I wasn't able to get any combination of CLASSPATH, LD_LIBRARY_PATH to work, which would have been the more elegant way...
Back to top
View user's profile Send private message
alistair
Retired Dev
Retired Dev


Joined: 15 Jul 2005
Posts: 869

PostPosted: Thu Jan 10, 2008 2:27 am    Post subject: Reply with quote

you can't combine the -jar and -classpath options

so either java -cp $(java-config .....):launcher.jar org.Path.To.Main.Class

or add a Manifest classpath entry to the launcher.jar
_________________
______________
Help the gentoo-java project. Visit Gentoo Java Project

what good are admin powers if you don't abuse them for personal gain - mark_alec
Back to top
View user's profile Send private message
rscott13
n00b
n00b


Joined: 09 Jan 2008
Posts: 3

PostPosted: Thu Jan 10, 2008 2:54 pm    Post subject: Reply with quote

Thanks for the tips - unfortunately, I'm not a java programmer, so I'll have to figure out how to use them.

Assuming I'm successful, will they be portable enough to warrent sending them to the original author of the code?
Or is this stuff gentoo specific?
Back to top
View user's profile Send private message
alistair
Retired Dev
Retired Dev


Joined: 15 Jul 2005
Posts: 869

PostPosted: Thu Jan 10, 2008 9:59 pm    Post subject: Reply with quote

rscott13 wrote:
In case anyone else runs in to this, I hacked around the problem by physically coping the files into the right location.

First, make sure you know which version of java is in use:
java -version

java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Server VM (build 1.6.0_02-b05, mixed mode)

Go to the java ext lib:
cd /opt/sun-jre-bin-1.6.0.02/lib/ext

Copy the RXTXcomm.jar:
cp -av $(java-config -p rxtx-2) .
`/usr/share/rxtx-2/lib/RXTXcomm.jar' -> `./RXTXcomm.jar'

Now go to binary lib:
cd ../i386
cp -av $(java-config -i rxtx-2)/* .
`/usr/lib/rxtx-2/librxtxI2C-2.1-7.so' -> `./librxtxI2C-2.1-7.so'
`/usr/lib/rxtx-2/librxtxI2C.so' -> `./librxtxI2C.so'
`/usr/lib/rxtx-2/librxtxParallel-2.1-7.so' -> `./librxtxParallel-2.1-7.so'
`/usr/lib/rxtx-2/librxtxParallel.so' -> `./librxtxParallel.so'
`/usr/lib/rxtx-2/librxtxRaw-2.1-7.so' -> `./librxtxRaw-2.1-7.so'
`/usr/lib/rxtx-2/librxtxRaw.so' -> `./librxtxRaw.so'
`/usr/lib/rxtx-2/librxtxRS485-2.1-7.so' -> `./librxtxRS485-2.1-7.so'
`/usr/lib/rxtx-2/librxtxRS485.so' -> `./librxtxRS485.so'
`/usr/lib/rxtx-2/librxtxSerial-2.1-7.so' -> `./librxtxSerial-2.1-7.so'
`/usr/lib/rxtx-2/librxtxSerial.so' -> `./librxtxSerial.so'

I wasn't able to get any combination of CLASSPATH, LD_LIBRARY_PATH to work, which would have been the more elegant way...


Please no!!!!! That is bad for SO many reasons
_________________
______________
Help the gentoo-java project. Visit Gentoo Java Project

what good are admin powers if you don't abuse them for personal gain - mark_alec
Back to top
View user's profile Send private message
alistair
Retired Dev
Retired Dev


Joined: 15 Jul 2005
Posts: 869

PostPosted: Thu Jan 10, 2008 10:00 pm    Post subject: Reply with quote

rscott13 wrote:
Thanks for the tips - unfortunately, I'm not a java programmer, so I'll have to figure out how to use them.

Assuming I'm successful, will they be portable enough to warrent sending them to the original author of the code?
Or is this stuff gentoo specific?


There should be nothing wrong with sending them off, but wouldn't the original author be more interested in the source?

Also remember to document the dependencies in some way.
_________________
______________
Help the gentoo-java project. Visit Gentoo Java Project

what good are admin powers if you don't abuse them for personal gain - mark_alec
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum