Vorane
Posts: 4
Joined: Thu Nov 13, 2014 1:09 am

Desktop Eclipse integration with RPi?

Mon Nov 17, 2014 3:05 am

Hey everyone,

To make a long story short, I've been using Java through the Eclipse IDE since the last 2-3 years. I've fallen in love with the language and the IDE. It's simple and able to support deeper stuff when needed. When I first bought the Raspberry Pi B+ model, I imagined the ram was enough to run an IDE like Eclipse, but sadly it just won't cut it. I am also lacking a permanent monitor, keyboard and mouse.

I was wondering if there was a way I could use Eclipse on my laptop to program for the RPi straight away, without the hassle of exporting .jars, copying them over via SSH, etc.

Now, I know this has been asked many many times on multiple forums, I research thoroughly Oracle's documentation on the subject, but without finding anything I was looking for. The only solution I found out was in this page ( https://docs.oracle.com/javame/config/c ... ugging.htm ), but it seems like you can only create classes extending MIDlet, which I don't want to.

Has anybody found an efficient way of, when pressing the run button, to export the code straight to the Pi and execute it?

Thanks in advance! I am really looking forward to play around with GPIO pins :D

ghp
Posts: 1408
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Desktop Eclipse integration with RPi?

Mon Nov 17, 2014 8:53 am

Hello,
I was wondering if there was a way I could use Eclipse on my laptop to program for the RPi straight away, without the hassle of exporting .jars, copying them over via SSH, etc.
Think you will always need to produce jars and to copy them over to a target system. This is how java deployment works. But you could use an ant build file to automate this task.
- build jar file
- copy to target system by ftp or scp
- and start execution on target by sshexec

ant build file editors are in java base install of eclipse.

It is also possible to include an ant file into the builders in eclipse. This full automation is slowing down the build process, so I never used this except for some experiments.

Regards
Gerhard

Vorane
Posts: 4
Joined: Thu Nov 13, 2014 1:09 am

Re: Desktop Eclipse integration with RPi?

Tue Nov 18, 2014 8:04 pm

Hey,

I know I have to do all the exporting / building / etc, but is there a way to simply automate this in Eclipse? I successfully seted up my remote environment in NetBeans, but I think I'm going to stick with it if I have no other choice.

Thanks anyways!

ghp
Posts: 1408
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Desktop Eclipse integration with RPi?

Tue Nov 18, 2014 8:40 pm

look for http://ant.apache.org/manual/index.html, there is a pretty smart manual on ant there.
ant is build automation tool, ready available in eclipse (java) or standalone.

In eclipse, place a file build.xml in root folder of your project.
Here some sample content:

Code: Select all

<?xml version="1.0"?>
<!--  -->
<project name="sample" default='all'>

	<description>
        Used to explain an ant file
    </description>


	<!-- Define base properties -->

    <property name="pi.host" value="10.0.0.1" />

    <property name="root.user" value="root" />
    <property name="root.password" value="password" />

    <property name="target.file" value="/home/pi/deploy.jar" />
    <property name="source.file" value="temp/deploy.jar" />

	<target name="all">
		<antcall target='build' />
		<antcall target='deploy' />
		<antcall target='run' />
	</target>

    <target name="build">
        <mkdir dir='temp' />
        <jar destfile="${source.file}" overwrite='yes' >
            <fileset dir='bin'>
                <include name='**/*class' />
            </fileset>
        </jar>
    </target>

	<target name="deploy">
		<scp file="${root.user}:${root.password}@${pi.host}:${source.file}"
                                  localTofile='files/${test.name}/current.dat' trust="yes" />
       </target>

    <target name="run">
        <sshexec command="java -jar  ${target.file}" host="${pi.host}" username="${root.user}" password="${root.password}" trust="yes" />
    </target>

</project>
This is not tested, but at least is a starting point.

Then, rightclick on the build.xml, and 'run as ant'.

regards,
Gerhard

User avatar
Douglas6
Posts: 4760
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Desktop Eclipse integration with RPi?

Wed Nov 19, 2014 12:39 am

Another way to go is to create a samba share on the Pi, and simply put your Eclipse workspace on it.

As they say around here, "Different horses for different courses".

RyuKajiya
Posts: 43
Joined: Fri Oct 31, 2014 9:46 am

Re: Desktop Eclipse integration with RPi?

Wed Nov 19, 2014 7:08 am

If you set it up in NetBeans allready you can look at the code that is generated from NetBeans. It contains everything you need to set up ant remote deployment, you just have to copy it over to your Eclipse project, set it up to use ant and fill in the variables.

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

Re: Desktop Eclipse integration with RPi?

Mon Nov 24, 2014 2:08 pm

For exact purpose I designed this: http://remotevm.abstracthorizon.org/

As it goes for integration with Eclipse it is explained here: http://remotevm.abstracthorizon.org/ecl ... orial.html. All I do is write code on my laptop in Eclipse, press run button and see result running on RPi in real time (minus amount of time for changed classes to be transferred to the RPi). Good thing only delta (at the file level) is passed across.

That makes is extremely fast: type, save, run; unlike other solutions where:
a) file system is remote and Eclipse reads (to check for changes) all files over network on slow target system + complication of setting up everything to run remotely - I.E. open ssh plus command line to start it up
b) compile whole jar and then all the complication...

It sends stdio back to Eclipse's console, you can debug it seamlessly from Eclipse, etc...

Tinue
Posts: 40
Joined: Fri Dec 05, 2014 12:48 pm

Re: Desktop Eclipse integration with RPi?

Fri Dec 05, 2014 12:52 pm

clicky wrote:For exact purpose I designed this: http://remotevm.abstracthorizon.org/
Thanks, I like this project! I almost gave up getting it up and running, though. It turns out that the launcher does not like blanks in either the Eclipse project name, or anywhere in the path to the Eclipse workspace. But after changing this it works fine.

Regards, Martin

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

Re: Desktop Eclipse integration with RPi?

Fri Dec 05, 2014 7:25 pm

Thanks for letting me know. I've been using it mostly with Linux/OSX. I'll be looking into it.

User avatar
gpio
Posts: 26
Joined: Wed Dec 03, 2014 10:19 pm
Location: Gran Canaria :: Spain

Re: Desktop Eclipse integration with RPi?

Sun Dec 07, 2014 10:04 am

Thanks very much!

I was looking for something like this.

Works fine to me, but I have problems with Debug. Surely I'm doing wrong.

No application loads.

Code: Select all

sudo java -jar remotevmlauncher-agent-1.0-20140103.103618-5ar -d 4
09:38:41.753  Starting agent at 0.0.0.0/0.0.0.0:8999
09:38:52.479 [1] !! Got client from ubuntu-EasyNote-TM98.local:49320 address.
09:38:52.599 [1] >> 
00000000  00 02 56 4d 00 00 1f 40  01 01 00 04 00 00 00 00 |[email protected]|

09:38:52.606 [1] !! Received packet with id: VM
09:38:52.611 [1] >> Client send 16 bytes to launcher
09:38:52.661 [1] !! Launching with classpath: /home/pi/remotevmlauncher-agent-1.0-20140103.103618-5.jar
09:38:52.690 [1] !! Launching command:  java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -cp /home/pi/remotevmlauncher-agent-1.0-20140103.103618-5.jar org.ah.java.remotevmlauncher.launcher.Launcher 58573
09:38:53.682 [1] << Waiting to send back stream data:
Listening for transport dt_socket at address: 8000

09:38:53.686 [1] << Waiting on stream data to be sent back...
09:38:53.899 [1] << Got writable for client channel
09:38:53.903 [1] << Selecting new buffer to send
09:38:53.907 [1] << Selected stream buffer
09:38:53.922 [1] << 
00000000  00 02 53 30 00 33 4c 69  73 74 65 6e 69 6e 67 20 |..S0.3Listening |
00000010  66 6f 72 20 74 72 61 6e  73 70 6f 72 74 20 64 74 |for transport dt|
00000020  5f 73 6f 63 6b 65 74 20  61 74 20 61 64 64 72 65 |_socket at addre|
00000030  73 73 3a 20 38 30 30 30  0a                      |ss: 8000.|

09:38:53.931 [1] << Got writable for client channel
09:38:53.935 [1] << Buffer is completely sent. Finishing it...
09:38:53.940 [1] << It was stream - notifying it...
09:38:53.944 [1] << Waiting on stream data was sent back.
09:38:53.949 [1] << Got writable for client channel
09:38:53.966 [1] << Selecting new buffer to send
09:38:53.971 [1] << Selected new buffers; streamBuffer ready=false, throughput ready=true, launcherToClientBufferReady=false
09:38:53.975 [1] << Removing WRITE from client channel
https://docs.google.com/file/d/0Bz3s-4T ... edit?pli=1

Best regards

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

Re: Desktop Eclipse integration with RPi?

Sun Dec 07, 2014 11:24 am

"suspend=y," is the key. If you omit '--remote-debug-suspend' then it will be 'suspend=n' which means app will start immediately without waiting for you to attach to it for debugging.
Anyway - remotevm doesn't do anything debugging wise - it just passes parameters to remote vm for it to listen to port/wait for debugger to be attached. Idea is that you don't want always to run app until debugger is attached - so 'suspend=y' (or '--remote-debug-suspend' passed from the client) tells newly created vm to wait for debugger before continuing.

Anyway - important part is that, after you asked for debug/suspend to create another Eclipse launcher for your main app for debugging. In 'Debug configurations' you'll see 'Remote Java Application' - select your project, your rpi's address and port you specified in '--remote-debug-port', and start debugging. If you had 'suspend=y' ('--remote-debug-suspend' in your client args) then the moment it attaches to remove JVM it will start executing (and hitting your break points if you have set any).

Give it a go and let me know if my explanation is confusing - I can write up something like step by step tutorial...

User avatar
gpio
Posts: 26
Joined: Wed Dec 03, 2014 10:19 pm
Location: Gran Canaria :: Spain

Re: Desktop Eclipse integration with RPi?

Sun Dec 07, 2014 12:02 pm

For me it is enough.

Thank you very much for your explanation and for the quick response.

I can already debug! :D

https://drive.google.com/open?id=0Bz3s- ... authuser=0


Best regards!

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

Re: Desktop Eclipse integration with RPi?

Sun Dec 07, 2014 2:48 pm

:) I'm glad to be of help...

Strangely enough - after months of doing something else, last three weeks I am using remotevm tool myself again - making some 3d printer toolset software in java. And it just works!

I'm going to look at Windows paths (and spaces) and bump version to 1.0! And move source to github!

Return to “Java”