LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-24-2012, 04:38 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
linux and java: javax.comm works in linux?


Hi!

I'm goint to test an application that uses javax.comm to handle some serial ports. It was developed in windows and now I'm going to use it on linux (on x86 but then I'll move it to a DreamPlug so it will be running on ARM).

I'm listing the available ports on my box and I see none (and I have a USB dongle that provides 3 ports, ttyUSB0 1 and 2).

Code:
Enumeration<CommPortIdentifier>	ports = CommPortIdentifier.getPortIdentifiers();
System.out.println("Puertos disponibles:");
while (ports.hasMoreElements()) {
	CommPortIdentifier port = ports.nextElement();
	System.out.println(port.getName());
}
System.out.println("Eso es todo");
Result:
Code:
Puertos disponibles:
Eso es todo
Be it as a normal user or as root. Is this api supported in linux (again, keep in mind I'll put it on ARM later on)?

I could just use one abstraction layer to handle javax.comm on windows and use the serial port device directly on linux but would like to skip it if possible.

Thanks in advance.
 
Old 08-25-2012, 09:07 AM   #2
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 609

Rep: Reputation: 180Reputation: 180
Maybe you're lacking platform specific support (read: JNI libraries) for javax.comm on Linux.
If you look at this old page, it seems like you need to install rxtx first, then you should be able to use the javax.comm API flawlessly upon proper configuration.
 
Old 08-25-2012, 12:20 PM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
Well, this is fairly interesting. I was able to list the serial ports available after working with rxtx on my box.

Now I want to be able to do the same thing on the beagleboard. I downloaded rxtx and compiled it there. Now see what happens when I try to run it:

Code:
$ java -cp bin:lib/comm.jar:/home/ubuntu/Downloads/rxtx-2.1-7r2/RXTXcomm.jar la.cps.comm.SimpleRead
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Error al tratar de listar los dispositivos
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
        at java.lang.Runtime.loadLibrary0(Runtime.java:840)
        at java.lang.System.loadLibrary(System.java:1047)
        at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
        at la.cps.comm.SimpleRead.main(SimpleRead.java:34)
Caught java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver while loading driver gnu.io.RXTXCommDriver
port /dev/ttyUSB0 not found.
$ export LD_LIBRARY_PATH=/home/ubuntu/Downloads/rxtx-2.1-7r2/armv7l-unknown-linux-gnu/.libs/
$ java -cp bin:lib/comm.jar:/home/ubuntu/Downloads/rxtx-2.1-7r2/RXTXcomm.jar la.cps.comm.SimpleRead
java.lang.UnsatisfiedLinkError: gnu.io.RXTXCommDriver.nativeGetVersion()Ljava/lang/String; thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver
Lista de puertos disponibles
Eso es todo

Caught java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver while loading driver gnu.io.RXTXCommDriver
port /dev/ttyUSB0 not found.
So I guess the problem has to deal with the so from rxtx. Any ideas how I should move ahead? Thanks in advance
 
Old 08-25-2012, 07:03 PM   #4
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
Ok.... After a lot of fiddling I ended up being able to use rxtx on the beagleboard.
Had to hack it a little bit in order to build it (given that utsrelease.h has moved location or something).

Will try on the dreamplug on monday.
 
Old 08-25-2012, 07:05 PM   #5
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
Oh... forgot to mention that I was able to make it work on rxtx-2.2 (prerelease)
 
  


Reply

Tags
comm, java, javax, javax.comm, linux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for javax.comm for Linux in oracle.com K1LL3R DO6 Programming 2 12-05-2011 01:46 AM
javax.comm for /dev/ttyS* IO errors tomax26 Programming 0 02-25-2010 08:04 AM
Where to find the JARs for javax.swing.* and java.awt.* jlinkels Programming 5 01-02-2009 07:46 PM
Bluez and javax.comm ---> NoSuchPortException philipina Programming 1 06-24-2004 09:16 AM
javax comm for suse linux kingshrimp Linux - Newbie 4 11-26-2003 09:19 AM


All times are GMT -5. The time now is 10:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration