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

Remote development on RPi

Tue Dec 31, 2013 1:22 pm

Or I would like to share 'remote' gyro testing rig I've done:
Rig is setting board at -45º, wait for a second move it to 45º while constantly collecting data every 25ms (each gyro has separate Java classes that test it) and send data back at the end on System.out (that comes back to Eclipse's console). It doesn't matter how close to RPi I am any more (living room with family as opposite alone in my 'study' or miles away) - with RPi camera and hardware/software above, I can develop Java code for RPi (and associated hardware) in Eclipse on my laptop and see the results immediately (well - with 2 second delay) back on my laptop.

Here's my desktop screenshot:
Image

Next is 'remote' libgdx development for RPi! :D (I'll do little write up in next few days).

PS: here's my RPi camera pan/tilt setup:
Image

PIsingh
Posts: 12
Joined: Tue Dec 24, 2013 11:52 pm

Re: Remote development on RPi

Tue Dec 31, 2013 11:57 pm

Seem like you have mastered the VM stuff. I am a beginner , Can i get some help on setting up the Remote VM, i have followed the turtorial on http://remotevm.abstracthorizon.org/ecl ... orial.html , I have put the vm client jar on pi, and it running while on the eclipse, i press run. (not too sure hw this vm stuff works technically)
But what i like to do is complie my code on the pi and transfer the jar file to the pi.
help please thx.
BTW i am running java 7, (not sure abt the headless stuff either)

Error details
<--Pi4J--> GPIO Control Example ... started.
java.io.IOException: Cannot run program "bash": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at com.pi4j.util.ExecUtil.execute(ExecUtil.java:45)
at com.pi4j.util.ExecUtil.execute(ExecUtil.java:40)
at com.pi4j.system.SystemInfo.getBashVersionInfo(SystemInfo.java:441)
at com.pi4j.system.SystemInfo.access$000(SystemInfo.java:43)
at com.pi4j.system.SystemInfo$2.run(SystemInfo.java:193)
at com.pi4j.system.SystemInfo$2.run(SystemInfo.java:190)
at java.security.AccessController.doPrivileged(Native Method)
at com.pi4j.system.SystemInfo.isHardFloatAbi(SystemInfo.java:190)
at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:153)
at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:138)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:47)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:102)
at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:67)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:85)
at org.ah.remotevm.tutorial.GpioExample.main(GpioExample.java:13)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:385)
at java.lang.ProcessImpl.start(ProcessImpl.java:136)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 18 more
java.io.IOException: Cannot run program "/usr/bin/readelf": CreateProcess error=3, The system cannot find the path specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at com.pi4j.util.ExecUtil.execute(ExecUtil.java:45)
at com.pi4j.util.ExecUtil.execute(ExecUtil.java:40)
at com.pi4j.system.SystemInfo.getReadElfTag(SystemInfo.java:472)
at com.pi4j.system.SystemInfo.hasReadElfTag(SystemInfo.java:459)
at com.pi4j.system.SystemInfo.access$100(SystemInfo.java:43)
at com.pi4j.system.SystemInfo$2.run(SystemInfo.java:193)
at com.pi4j.system.SystemInfo$2.run(SystemInfo.java:190)
at java.security.AccessController.doPrivileged(Native Method)
at com.pi4j.system.SystemInfo.isHardFloatAbi(SystemInfo.java:190)
at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:153)
at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:138)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:47)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:102)
at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:67)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:85)
at org.ah.remotevm.tutorial.GpioExample.main(GpioExample.java:13)
Caused by: java.io.IOException: CreateProcess error=3, The system cannot find the path specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:385)
at java.lang.ProcessImpl.start(ProcessImpl.java:136)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 19 more
java.io.IOException: Cannot run program "bash": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at com.pi4j.util.ExecUtil.execute(ExecUtil.java:45)
at com.pi4j.util.ExecUtil.execute(ExecUtil.java:40)
at com.pi4j.system.SystemInfo.getBashVersionInfo(SystemInfo.java:441)
at com.pi4j.system.SystemInfo.access$000(SystemInfo.java:43)
at com.pi4j.system.SystemInfo$2.run(SystemInfo.java:193)
at com.pi4j.system.SystemInfo$2.run(SystemInfo.java:190)
at java.security.AccessController.doPrivileged(Native Method)
at com.pi4j.system.SystemInfo.isHardFloatAbi(SystemInfo.java:190)
at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:154)
at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:138)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:47)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:102)
at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:67)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:85)
at org.ah.remotevm.tutorial.GpioExample.main(GpioExample.java:13)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:385)
at java.lang.ProcessImpl.start(ProcessImpl.java:136)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 18 more
java.io.IOException: Cannot run program "/usr/bin/readelf": CreateProcess error=3, The system cannot find the path specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at com.pi4j.util.ExecUtil.execute(ExecUtil.java:45)
at com.pi4j.util.ExecUtil.execute(ExecUtil.java:40)
at com.pi4j.system.SystemInfo.getReadElfTag(SystemInfo.java:472)
at com.pi4j.system.SystemInfo.hasReadElfTag(SystemInfo.java:459)
at com.pi4j.system.SystemInfo.access$100(SystemInfo.java:43)
at com.pi4j.system.SystemInfo$2.run(SystemInfo.java:193)
at com.pi4j.system.SystemInfo$2.run(SystemInfo.java:190)
at java.security.AccessController.doPrivileged(Native Method)
at com.pi4j.system.SystemInfo.isHardFloatAbi(SystemInfo.java:190)
at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:154)
at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:138)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:47)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:102)
at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:67)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:85)
at org.ah.remotevm.tutorial.GpioExample.main(GpioExample.java:13)
Caused by: java.io.IOException: CreateProcess error=3, The system cannot find the path specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:385)
at java.lang.ProcessImpl.start(ProcessImpl.java:136)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 19 more
Dec 31, 2013 3:18:33 PM com.pi4j.util.NativeLibraryLoader load
SEVERE: Failed to load library [pi4j] using the System.load(file) method using embedded resource file: [jar:file:/C:/Documents%20and%20Settings/Administrator/Workspaces/Eclipse%20Standard%20431/eclipse-remote-vm-pi4j-rpi-tutorial/lib/pi4j-core.jar!/lib/soft-float/libpi4j.so]
Dec 31, 2013 3:18:33 PM com.pi4j.util.NativeLibraryLoader load
SEVERE: ERROR: The native library [pi4j : libpi4j.so] could not be found in the JVM library path nor could it be loaded from the embedded JAR resource file; you may need to explicitly define the library path '-Djava.library.path' where this native library can be found.
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.pi4j.wiringpi.Gpio.wiringPiSetup()I
at com.pi4j.wiringpi.Gpio.wiringPiSetup(Native Method)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:47)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:102)
at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:67)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:85)
at org.ah.remotevm.tutorial.GpioExample.main(GpioExample.java:13)

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

Re: Remote development on RPi

Wed Jan 01, 2014 4:34 pm

From what I can gather from the stack trace, it seems that you're trying to run the example on your PC. In Eclipse run (launch) configuration, you should put "org.ah.java.remotevmlauncher.client.LaunchRemote" for MainClass on the first tab (not org.ah.remotevm.tutorial.GpioExample) and on Arguments tab, put:

<your-rpi-address>:8998
org.ah.remotevm.tutorial.GpioExample
--

(note "--" at the end, in next row after it you can put your main class arguments)

HTH

BTW - I have put new version of client and agent jars and fixed some mistakes on the tutorial and usage pages.

Caustic
Posts: 8
Joined: Fri Jun 07, 2013 4:31 am

Re: Remote development on RPi

Thu Jan 02, 2014 1:23 am

Hey. I just gave this a try, it looks great but I keep getting a ClassNotFoundException I can't figure out.

Code: Select all

java.lang.ClassNotFoundException: remotevmtest.GpioExample
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.ah.java.remotevmlauncher.launcher.Launcher.prepareForStartApplication(Launcher.java:278)
	at org.ah.java.remotevmlauncher.launcher.Launcher.start(Launcher.java:237)
	at org.ah.java.remotevmlauncher.launcher.Launcher.main(Launcher.java:550)
My run config arguments:

Code: Select all

192.168.1.76:8999
remotevmtest.GpioExample
--
Can't figure out why it would do this, I only ever use Eclipse so I'm not too sure about setting classpaths and stuff but I shouldn't need anything special. Can't even get a System.out to print. :D

Any tips? And do you have a thread or your own forum for remotevm?
Thanks

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

Re: Remote development on RPi

Thu Jan 02, 2014 9:50 am

Ok, this is close now. Shouldn't your configuration read, then:

Code: Select all

192.168.1.76:8999
org.ah.remotevm.tutorial.GpioExample
--

Zachster1996
Posts: 58
Joined: Wed Aug 14, 2013 7:16 am

Re: Remote development on RPi

Thu Jan 02, 2014 1:36 pm

If you are doing stuff with GPIO, I suggest one of 2 things.

Write this in Python

OR

Use a Python wrapper and execute sudo python FileName.py

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

Re: Remote development on RPi

Thu Jan 02, 2014 1:50 pm

But this is not the point. If you're writing things in Python, then you go to Python part of the forum and ask for help here. But, if you want to do it in Java, then this is the place to ask for help.

Also, there are a few reasons why some things might be better written in Java than Python, even if they do involve GPIO...
So, can we concentrate to the topic, please? :)

kevinmaes
Posts: 1
Joined: Thu Jan 02, 2014 11:50 pm

Re: Remote development on RPi

Fri Jan 03, 2014 12:03 am

I'm having the same problem here:

Code: Select all

java.lang.ClassNotFoundException: org.ah.remotevm.tutorial.GpioExample
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.ah.java.remotevmlauncher.launcher.Launcher.prepareForStartApplication(Launcher.java:278)
	at org.ah.java.remotevmlauncher.launcher.Launcher.start(Launcher.java:237)
	at org.ah.java.remotevmlauncher.launcher.Launcher.main(Launcher.java:550)
On the rasp side:

Code: Select all

[email protected] ~ $ sudo java -jar remotevmlauncher-agent-1.0-20131229.110135-4.jar -d 3
00:45:57.473  Starting agent at 0.0.0.0/0.0.0.0:8999
00:46:11.355 [1] !! Got client from d54C40C5F.access.telenet.be:49988 address.
00:46:11.478 [1] >> Client send 16 bytes to launcher
00:46:11.520 [1] !! Launching with classpath: /home/pi/remotevmlauncher-agent-1.0-20131229.110135-4.jar
00:46:11.545 [1] !! Launching command:  java -cp /home/pi/remotevmlauncher-agent-1.0-20131229.110135-4.jar org.ah.java.remotevmlauncher.launcher.Launcher 54838
00:46:13.178 [1] << Launcher connected back to us
00:46:13.298 [1] << Launcher sent 4 bytes to client 
00:46:14.628 [1] >> Client send 4 bytes to launcher
00:46:14.637 [1] >> Client send 1024 bytes to launcher
00:46:14.649 [1] >> Client send 1024 bytes to launcher
00:46:14.660 [1] >> Client send 864 bytes to launcher
00:46:14.848 [1] << Waiting to send back stream data:
java.lang.ClassNotFoundException: org.ah.remotevm.tutorial.GpioExample
00:46:14.918 [1] << Waiting to send back stream data:

	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.ah.java.remotevmlauncher.launcher.Launcher.prepareForStartApplication(Launcher.java:278)
	at org.ah.java.remotevmlauncher.launcher.Launcher.start(Launcher.java:237)
	at org.ah.java.remotevmlauncher.launcher.Launcher.main(Launcher.java:550)
What's going wrong? I tried fiddling with the class path in eclipse to include the maven target classes as well, but these are included by default. I also tried passing the classes in through the remoteclasspath setting, but still nothing.

Caustic
Posts: 8
Joined: Fri Jun 07, 2013 4:31 am

Re: Remote development on RPi

Fri Jan 03, 2014 3:32 am

Unless I have to use your package structure for my program no, the class is definitely remotevmtest.GpioExample

Edit: I just looked inside the ~/.remotevm folder. Is this how things should appear?

Code: Select all

folder - ~/.remotevm
     folder - removmtest.GpioExample
          folder - bin
               file - remotevmtest\GpioExample.class
          file - .dirs
I've never seen java classes with backslashes in the name but then I have no idea how remotevm does it's thing. :3

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

Re: Remote development on RPi

Fri Jan 03, 2014 9:31 am

Caustic wrote:Edit: I just looked inside the ~/.remotevm folder. Is this how things should appear?

Code: Select all

folder - ~/.remotevm
     folder - removmtest.GpioExample
          folder - bin
               file - remotevmtest\GpioExample.class
          file - .dirs
I've never seen java classes with backslashes in the name but then I have no idea how remotevm does it's thing. :3
Oops. That's probably it! Sorry O: )

I have tested all (before tutorial) on Windows (virtual) machine, but now when I am thinking about it, I might have NOT used package for the 'test' class in that case. So, that's another place I need to do 'Windows' to '*nix' file string translations (simple replaceAll("\\", "/")). I'll do it today!

BTW package structure doesn't matter, I was just worried that you followed all as in tutorial, but forgot to put first part of the path. You can try 'default' package class until I sort out file path issue.

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

Re: Remote development on RPi

Fri Jan 03, 2014 10:42 am

That was it. I managed to recreate the problem and fix it! :)

New version of the client (and agent, but there are not changes in the agent, really) are available on download page (and in repository):

http://remotevm.abstracthorizon.org/downloads.html

Hope it will work now! :)

Caustic
Posts: 8
Joined: Fri Jun 07, 2013 4:31 am

Re: Remote development on RPi

Fri Jan 03, 2014 4:55 pm

That's great clicky, thanks for your hard work. I'll try it out as soon as I get a chance.

Return to “Java”