raspdroid
Posts: 1624
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Provided arguments to Remote VM

Wed Jan 14, 2015 11:25 pm

Hello,

I use these arguments to use the rxtxSerial library in Raspberry Pi :

Code: Select all

java -Djava.library.path=/usr/lib/jni/ -jar application.jar 
But how to do it in Remote VM?

I tried so:

Code: Select all

--remote-classpath
/usr/lib/jni
192.168.1.50:8998
application.Main
--
But not work to me. I get this exception:

Code: Select all

INFO: [/dev/ttyAMA0 - 9600/8/N/1/N] Opening the connection interface...
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
What is the right way?

Best regards

raspdroid
Posts: 1624
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: Provided arguments to Remote VM

Thu Jan 15, 2015 11:21 am

Hello,

I cleaned all arguments of the project.

In Build Path > Configure > Libraries > select rxtx-2.2.jar > + > select native library location > Edit > and add /usr/lib/jni

I use this code to see java.library.path in Main application (JavaFX).

Code: Select all

 static {
		 String property = System.getProperty("java.library.path");
		 StringTokenizer parser = new StringTokenizer(property, ";");
		 while (parser.hasMoreTokens()) {
		     System.err.println(parser.nextToken());
		     }
		  }

Running in LocalHost is all correct:

Code: Select all

/usr/lib/jni
INFORMACIÓN: [/dev/ttyAMA0 - 9600/8/N/1/N] Opening the connection interface...
WARNING:  RXTX Version mismatch
	Jar version = RXTX-2.2pre1
	native lib Version = RXTX-2.2pre2
In RemoteHost (Raspberry Pi) I added this in run configurations but the path to jni directory not appears:
--remote-classpath
/usr/lib/jni
192.168.1.50:8998
application.Main
--

Code: Select all

/usr/java/packages/lib/arm:/lib:/usr/lib
INFO: [/dev/ttyAMA0 - 9600/8/N/1/N] Opening the connection interface...
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver



PD: At the moment I resolved so:

cd /usr/lib
sudo ln -s /jni/librxtxSerial.so .

Code: Select all

/usr/java/packages/lib/arm:/lib:/usr/lib
Jan 15, 2015 11:24:27 AM com.digi.xbee.api.XBeeDevice open
INFO: [/dev/ttyAMA0 - 9600/8/N/1/N] Opening the connection interface...
WARNING:  RXTX Version mismatch
	Jar version = RXTX-2.2pre1
	native lib Version = RXTX-2.2pre2

User avatar
clicky
Posts: 499
Joined: Thu Oct 25, 2012 7:34 am

Re: Provided arguments to Remote VM

Fri Jan 16, 2015 8:51 am

Sorry to kept you waiting and your question is quite valid. Yes, it seems that I had similar problem and I have solved it but forgot to update usage output of client jar.

Anyway you need to use --remote-VM-argument or -rvma followed by argument passed to each newly started VM (by remote agent, of course).

So, something like:

Code: Select all

--remote-VM-argument
-Djava.library.path=/usr/lib/jni/
192.168.1.50:8998
application.Main
-- 
Right now I am not next to my RPi so I can double check it, but will do it later.

On slightly different subject - I have been doing what you are very recently and adopted slightly different approach: avoided RxTx library provided directly on Pi but embedded one in resulting code (jar) itself. That way I don't care if it is installed or Pi or not. Even better, same code can smartly decide to use different .so file and work on Linux. Or OSX! (I've covered both). And, after all, Windows, too!

Have a quick look at: https://github.com/natdan/rbx-toolset/t ... obox/comms

Send me a PM if you are interested to go further with it, as it would be nice to make little open source project to allow such multi-platform access to RxTx library. Or at least to refine solution I've done so far...

raspdroid
Posts: 1624
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: Provided arguments to Remote VM

Tue Jan 20, 2015 9:49 pm

Hello,

Sorry, I have not been able to test it before.

Works well with -rvma

Thank you very much!.

Best regards

Return to “Java”