Mattradius
Posts: 1
Joined: Mon Mar 11, 2013 9:40 pm

Questions about Eclipse

Mon Mar 11, 2013 10:01 pm

Well this is my first post, and I'm a little worried I'm about to sound like an idiot so please bear with me.

I'm a fairly recent Computer Science graduate (2011), and as part of my degree I learned VB and C++ using the Visual Studio development package. Outside of that I have very little experience with other environments, save Eclipse, which I started playing around with in my final year as I wanted to try my hand at Java programming. I didn't get very far but enjoyed the language.

I've just picked up a Raspberry Pi specifcally because I've missed programming (my current career doesn't require it), so thought I'd pick up Java again where I left off and was looking for advice on where best to start. Sadly the internet has been most unhelpful, and different people say different things. I have some ideas of what I want to do, but am unsure.

Essentially it boils down to this:

I'm aware that I can simply install Eclipse and run it on the RPi, but most people claim that it's very slow and is best run on a dedicated linux machine that you connect the Pi to. While I have access to a desktop Linux machine, the sorts of programming/coding I'm looking to do will be very basic. We're talking no GUIs yet, just command line imputs, array lists, loops and simple read-write commands. People have mentioned performance issues but realistically am I likely to suffer performance issues at this level, or am I going to be fine until I start to complile more substantial programs? Similarly, do I need to partition my drive in order to install a Java Environment?

Feel free to ask questions if it would help you give better advice. I'm not being deliberately vague, just trying to be concise.

Mat

User avatar
crackers
Posts: 55
Joined: Fri Dec 28, 2012 7:45 am

Re: Questions about Eclipse

Tue Mar 12, 2013 5:26 am

No, you don't have to have a Linux machine to develop Java code on. It's just not recommended that you do it on the Pi, especially using something rather heavy-weight like Eclipse (it runs on Windows and Mac, too). Those kinds of IDEs have a lot of bells and whistles, while the Pi does not. Ergo, runs really slowly.

You just need to be able to copy the finished .jar file(s) to the Pi (just like you'd copy your Java programs to another machine).

Performance, well, that comes under the "it depends" category -- you're not going to be able to run high-performance application servers and/or mega-web sites, but you can run small ones, like web apps.

No, you don't need to partition your drive. That sounds a little... off. I'm not sure where you got that notion from, but if it was from an on-line source, I'd consider them suspect. Just install OpenJDK on the Pi through the package management software and you'll be fine.

As for (re-)learning Java, you might try the "Headfirst" books -- I've heard they're very good, especially for those with a bit of experience behind them.

Chtonoid
Posts: 6
Joined: Mon Jan 21, 2013 8:15 pm

Re: Questions about Eclipse

Wed Mar 13, 2013 12:58 pm

Hi,

I just read your conversation on using Eclipse to develop java application on the Raspberry Pi.

I am using the pi4j api in order to access Raspberry Pi GPIO in my java program. The problem I have is when I want to test my program by clicking the Run button in Eclipse the JDK returns an error concerning the pi4j api who cannot run on another computer than the Raspberry Pi. It makes sense as there are no GPIO on my laptop !

I was wondering if it was possible to setup Eclipse to build and run my program directly on the raspberry in order to make quick tests ? Or is there another way to make pi4j application development easier than transferring exported jar files ?

Thanks

paulknewton
Posts: 45
Joined: Tue Mar 12, 2013 9:17 pm
Location: Luxembourg

Re: Questions about Eclipse

Wed Mar 13, 2013 1:22 pm

I think you will struggle to run a Java IDE such as Eclipse on the Pi. Eclipse is really quite a large animal these days. It already pushes my laptop well beyond it's comfort zone.

If you just want to execute Java programs on your Pi, then you just need the JVM virtual machine executable. You would develop and compile on another machine - then transfer to the Pi to run it.

If you want to compile the Java code into Java byte code on the Pi - then just run the Java compiler on the Pi, then run the JVM as above to execute the resulting code afterwards.

But that is still not 'developing' on the Pi. If you really want to host some kind of development environment on the Pi to allow you to code, compile, run, debug, fix, test...I think you will need to be a bit more creative.

A number of posts on here have pointed to some lighter IDEs. I have not tried these. I would be a little sceptical that you can get a reasonable performance in terms of interativity and responsiveness.

You could try a basic editor with Java syntax highlighting which might be good enough. You could always just write the code directly in a text editor. It might sound basic, but that is exactly what all of us of more - ahem - 'mature' developers used to do for years before UNIX finally got Eclipse and other graphical IDEs. I did all my C++ development with Emacs and 'make'. I did a lot of my early Java certification just using an editor and running the Java compiler directly. I still know many professional developers that code in 'vi'.

In a strange way, using the basic low-level tools will give you a much better understanding of the language and how it works (I personally would never go back to this, as I miss all of the useful features like refactoring, lookups etc. that a modern IDE gives you).

In short, you will be able to get a long way with the Pi. You can almost certainly find ways to write and compile Java code on the Pi. But out of fairness to the Pi, it is asking an awful lot for a 25 pounds computer to run a full modern graphical development environment.

Of course, the best advice I can give you is to give it a go. Get the latest Java tools from the repository and see how they run. You might be surprised.

Good luck.

paul.

Chtonoid
Posts: 6
Joined: Mon Jan 21, 2013 8:15 pm

Re: Questions about Eclipse

Wed Mar 13, 2013 1:57 pm

Hi Paul,

Thank you for your quick answer.

I will keep in mind your advice regarding vi.

Running Eclipse on the Raspberry Pi was not I was thinking of. I was thinking about running eclipse on a laptop or desktop computer networked with the RasPi. I was wondering it there was a way to setup Eclipse (running on the laptop) to build and run the Java application on the RasPi.

To make it easier to understand maybe we can make a parrallel with Microcontroler programing. I used to program Pic microcontrolers in C with a Pic developpment board. The ide you use to do that ( ie MPLAB) builds the program and loads it into the Pic flash and then run it on the Pic device. I was wondering if it was possible to do that with a RaspberryPi and Eclipse running on a laptop ?

Thanks

Christophe

paulknewton
Posts: 45
Joined: Tue Mar 12, 2013 9:17 pm
Location: Luxembourg

Re: Questions about Eclipse

Wed Mar 13, 2013 2:14 pm

Christophe -

If you compile your Java code in Eclipse, you can share the place where the .class (i.e. the bytecode that is produced by the Java compiler) between your Linux machine and your Pi. A simple Samba share will do this.

There is no need to compile the code on the Pi (that is the main advantage of Java that uses a virtual machine: your Java programs are compiled into a single, platform-independent set of bytecode that will run on any platform with a JVM).

In terms of running the compiled code on the Pi - just launch the JVM from the Pi command line. You could perhaps put together something that would allow Eclipse to remotely invoke the JVM on the Pi, but I think this is probably a little unnecessary (just open a SSH terminal on the Pi and run the command!). You can remotely invoke commands on a linux machine but I think it is really over-complicating things.

paul.

mseries
Posts: 1
Joined: Mon Jun 24, 2013 8:29 am

Re: Questions about Eclipse

Mon Jun 24, 2013 8:42 am

To the OP you don't need Eclipse to create Java applications of any sort. For simple ones you can use the tools that come with the JRE: (the compiler java and the JVM java). You'll need a text editor of course to create the files. Take a look at Apache ANT which you can use to help you do these tasks once you get more involved.

I create my Java on my Linux laptop and deploy it to the Pi for final testing. Fo Pi specific stuff such as GPIO I'd create a set 'mock' objects with the same interface as the real thing to enable me to do some local tests.

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

Re: Questions about Eclipse

Mon Jul 01, 2013 3:49 pm

Hello,

eclipse is a little bit to bulky for tiny raspberry.
I use eclipse to develop C, python and java code for the pi, but run it remote on a linux desktop machine.

For python, I transfer the source to pi and run it there. Be sure not to transmit the pyc-files.
For C, I transmit the sources and build files, and run make on the pi then.
For Java, I pack the classes to jars and transmit to target.

For these deployment procedures, I use ant tasks which ftp files, and sshexec for permission settings, make start or alike. This is all included in the eclipse ecosystem.

Greetings
Gerhard

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Questions about Eclipse

Mon Jul 01, 2013 4:21 pm

You can ssh -X inot the pi and use the laptop display of a linux laptop. The pi is quite slow at eclipse, and the jar size it can handle is a lot smaller than on a laptop. I'm still no further with a small IDE myself (some research but little done).
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

spooker
Posts: 9
Joined: Thu Jul 04, 2013 12:52 pm

Re: Questions about Eclipse

Thu Jul 04, 2013 3:29 pm

I am using Intellij 12 to build my applications.
You can configure intellij to sync java files automatically from your desktop (e.g. windows 7 ) to your raspberry by using SFTP (tools/deployment/configuration)

I want to go one step further and trigger remote run on the raspberry from Intellij so that I don't have to manually call java on the raspberry and set classpaths everytime etc etc. Any thoughts or alternative solutions to this?

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Questions about Eclipse

Thu Jul 04, 2013 4:04 pm

The JVM does accept the CLASSPATH environment variable. I'm sure it can be put in the shell config script. Now back to thinking about LF/CR/TAB/BS/DEL specials, and rendering strings to a lanterna Screen class, with minimum use of String allocations. :) In this incarnation I'm developing the editor first, instead of the language compiler. All Java of course, laptop for speed of development.

EDIT: P.S. should not sudo apt-get install java do sudo apt-get install default-jre libjogl* pi4j lanterna ... just to cut back on the wonderful world of Java stack trace fun? As I notice many are old or not packaged.
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

RoyLongbottom
Posts: 283
Joined: Fri Apr 12, 2013 9:27 am
Location: Essex, UK
Contact: Website

Re: Questions about Eclipse

Thu Jul 04, 2013 10:57 pm

My way is to compose or convert and edit programs on a PC, then transfer them to the RPi for compilation. These are benchmarks and compile time was between 8 and 36 seconds, the latter for 2500 lines of code. I used Eclipse for converting the benchmarks to run via Android but prefer to use simple Terminal compile and run commands, as I did for the Linux varieties. Amongst these are on-line and off-line Java Whetstone benchmarks and my JavaDraw test. These Java programs can be compiled, to produce .class files, using the same javac command via Windows and Linux, including on the RPi, but you should be aware that there are incompatibilities between the various versions of JDK and JRE (like 6, 7 and 8). More details on how to do it, along with results, are in:

http://www.roylongbottom.org.uk/Raspber ... hmarks.htm

and if you want to play with some simple working Java codes, mine are in:

http://www.roylongbottom.org.uk/Raspber ... hmarks.zip

Everything free with no ads.

spooker
Posts: 9
Joined: Thu Jul 04, 2013 12:52 pm

Re: Questions about Eclipse

Fri Jul 05, 2013 7:03 pm

I don't see the point in compiling code on the raspberry.
IntelliJ can compile classes on your desktop very fast and then automatically transfer them to the raspberry.
Then from your raspberry you can run the program using the following line of code and Debug from Intellij.
sudo java -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y' Hello

RoyLongbottom
Posts: 283
Joined: Fri Apr 12, 2013 9:27 am
Location: Essex, UK
Contact: Website

Re: Questions about Eclipse

Fri Jul 05, 2013 11:35 pm

spooker wrote:I don't see the point in compiling code on the raspberry.
So how do those who only have a Raspberry Pi get their programs to work?

User avatar
crackers
Posts: 55
Joined: Fri Dec 28, 2012 7:45 am

Re: Questions about Eclipse

Sat Jul 06, 2013 3:38 am

All you need is the JDK and a text editor -- IDE's are niceties.

thradtke
Posts: 492
Joined: Wed May 16, 2012 5:16 am
Location: Germany / EL

Re: Questions about Eclipse

Tue Jul 09, 2013 7:26 am

EMACS or MicroEMACS (Jasspas ME compiles fine) work well on the Pi. Never seen better macro/recording capabilities on any editor thus far, it's worth getting into it. Along with it, the API Javadocs are all that's really needed to get started.

I'm aware it takes a lot for a Windows user to get used to emacs keyboard shortcuts. But it pays.
Rocket Scientist.

Return to “Java”