Page 1 of 1

STICKY: Integrating NetBeans for RPi Java Development

Posted: Wed Oct 30, 2013 12:48 pm
by sr29067
I've posted an entry on my blog, https://blogs.oracle.com/speakjava/entr ... spberry_pi that explains how to set things up so you can develop Java code using NetBeans on your laptop or PC and have the compiled code automatically copied to your Raspberry Pi. This helps make the Java development process quicker and simpler.

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Thu Nov 14, 2013 10:29 am
by Zerjillo
Thank you very much!

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Wed Jan 08, 2014 3:42 pm
by suipaste
When connecting to the Pi from a windows machine it asks you to change the directory to .ssh.

I'm a little confused on this bit "Change directory to .ssh and edit the authorized_keys file (don't worry if this does not exist). Paste the key information at the end of this file and save it." Can anyone expand upon these instructions in detail.

Cheers

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Wed Jan 08, 2014 3:58 pm
by topguy

Code: Select all

cd .ssh
nano authorized_keys
<paste keys>
<ctrl-o ctrl-x to save and exit>
cd ..

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Wed Jan 08, 2014 4:15 pm
by suipaste
Yeah I tried that and it doesn't exist.

Code: Select all

-bash: cd: .ssh: No such file or directory
How do I create it?

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Wed Jan 08, 2014 4:30 pm
by DBryant
From the command line the .ssh directory would be created when you create the keys for the user, for example with the command:

Code: Select all

ssh-keygen -t rsa
This will create the .ssh directory and create public and private keys. All permissions will be set appropriately.

Or you could:

Code: Select all

cd ~
mkdir .ssh
chmod 700 .ssh
if you preferred and then populate with the files you require for your specific needs

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Thu Feb 06, 2014 8:08 pm
by Fidelius
With the new Netbeans 8 for the new Java 8 (including its multimedia library Javafx), it's now easier than ever to run, debug and profile your Java applications on the Pi from within Netbeans running on a bigger development machine, like a Linux PC for example. The Netbeans 8 Whats-New page explicitly mentions our nice Pi:

NetBeans IDE 8.0 Beta Information
New Feature Highlights

Java
[..]
* Java SE Embedded support to deploy, run, debug or profile Java SE applications on an embedded device, such as Raspberry PI, directly from the NetBeans IDE.
(Let's ignore the Embedded bit for a moment, because meant is Oracle's standard Java SE 8 for Raspbian.)

The Netbeans Wiki lists a detailed description with snapshots how to enable the remote-run feature.

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Fri Nov 21, 2014 6:34 am
by Mike08
Can a java application in windows could run in raspberry pi through LAN?

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Fri Nov 21, 2014 8:04 am
by DougieLawson
No.

It can make a tcp/ip connection to a Java program running on the RPi to exchange data. (MQTT is a good protocol for that.)

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Fri Nov 21, 2014 8:16 am
by Fidelius
Mike08 wrote:Can a java application in windows could run in raspberry pi through LAN?
Could you be more specific, please?

Do mean that
a) the Java program runs on a Windows machine but its graphical or textual output should be shown on a Pi ?
Or other way round, i.e. that
b) the Java programs runs on the Pi but is shown on a Windows machine?

To do b) you'd need an X-server running on your Windows machine, so you could "ssh -X" to the Pi.
"gygwin" provides an X-server for Windows, and other programs do so, too.
Or use a Virtualbox on your Windows machine running a Linux guest then you can do either direction.
Or use Linux on your PC in the first instance. :-)

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Fri Nov 21, 2014 5:42 pm
by Mike08
What I mean is the a question. I'm planning to create an application on Windows 7, and run, compile and debug it on my raspberry pi. Can you help me accomplish my project. I will be using Netbeans IDE as the front end of the application and MySQL as the back end. Thanks for your ideas.

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Fri Nov 21, 2014 7:37 pm
by Fidelius
Mike, in case I understand you correctly that you want to develop the Java application on your PC's Netbeans but remote-debug and remote-run the Java application on the Pi, then this could be for you:

The Netbeans Wiki lists a detailed description with snapshots how to enable the remote-run feature.

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Sat Nov 22, 2014 3:43 am
by Mike08
Okay thanks for the help.. If everything goes wrong can i consult you again?

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Sat Nov 22, 2014 3:46 am
by Mike08
What about the connection of the Pi and my computer?
Can LAN will do?
or Wifi connectivity?

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Sat Nov 22, 2014 9:29 am
by Fidelius
Mike08 wrote:What about the connection of the Pi and my computer?
Can LAN will do?
or Wifi connectivity?
Both will do: you just connect your Pi and your PC to some router or similar, so that your Pi sees the PC and your PC sees the Pi.

Also you would have to start the SSH server on your Pi to allow remote connections from the PC, and this you can do in the Pi's console via "raspi-config" (or was it "raspiconfig").

Since obviously a LAN connection is usually faster and more stable, I'd prefer LAN however.

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Sun Nov 23, 2014 3:37 am
by Mike08
Okay,, thanks for the help.. :)

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Thu Jan 15, 2015 11:50 pm
by boneoh
I am very new to Raspberry Pi and NetBeans. Somewhat new to Java as well.

In playing with the RPi and NetBeans, it seems that the Java compilation is performed locally and the dist .jar file is simply copied to the RPi.

Using the NetBeans C/C++, it seems that you can actually compile on the RPi.

So my question is how to handle the library dependencies from the RPi to the local machine? I am using NetBeans on a Mac.

Is there a way to tell NetBeans to look on the RPi for the libraries? I am trying to check out the bglib samples, which refer to both the bglib and gnu.io

I have an SMB share setup on the RPi, is it simply a matter of changing the NetBeans platform config settings? Or do the library .jar files need to get copied to the Mac from the RPi? That seems lame, since the versions could easily get out of date. Also, the gnu.io stuff has installed .so files, what do I do with them?

Thanks!

Pete

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Thu Feb 12, 2015 12:49 pm
by mimi123
boneoh wrote:I am very new to Raspberry Pi and NetBeans. Somewhat new to Java as well.

In playing with the RPi and NetBeans, it seems that the Java compilation is performed locally and the dist .jar file is simply copied to the RPi.

Using the NetBeans C/C++, it seems that you can actually compile on the RPi.

So my question is how to handle the library dependencies from the RPi to the local machine? I am using NetBeans on a Mac.

Is there a way to tell NetBeans to look on the RPi for the libraries? I am trying to check out the bglib samples, which refer to both the bglib and gnu.io

I have an SMB share setup on the RPi, is it simply a matter of changing the NetBeans platform config settings? Or do the library .jar files need to get copied to the Mac from the RPi? That seems lame, since the versions could easily get out of date. Also, the gnu.io stuff has installed .so files, what do I do with them?

Thanks!

Pete
If it's a Pi2 , you can run NetBeans very fast on the Pi.
If older, running on the Pi should work but is slowww

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Sat Apr 18, 2015 11:40 am
by Nitrogen
The only problem i had with this is that i didn't understand the structure of Java platform off the bat. I was mostly set off-track by references to Java Embedded. If you're just looking to learn java - skip everything related to setting up Java Embedded. As long as you have oracle-java8-jdk(bundled with latest Raspbian) package installed you already have a JRE to make use of NetBeans remote integration. Unless you're looking to specifically develop embedded apps.

Because of mentioned confusion i wasn't sure what to put into "Remote JRE path" field, when adding a platform in NetBeans environment. With help of google i was able to find that default JVM binary resides at /usr/bin/java, but you only need to put "/usr" into "Remote JRE path" field, cuz apparently it already expects underlying directory structure. So if you're running latest Rasbian or have installed the oracle-java8-jdk package manually you already have all tools required.

Here are the guides i've used:
http://wiki.netbeans.org/JavaSEEmbeddedHowTo
https://netbeans.org/kb/docs/java/javase-embedded.html

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Thu Apr 21, 2016 5:43 am
by vikbaba
Any idea how to access Raspberry Camera in Java? I am creating an Application using swing, currently running on Desktop accessing Webcam to show video stream.

Any suggestion how it could be done using Raspberry Camera?

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Thu Apr 21, 2016 10:19 am
by topguy
vikbaba wrote:Any idea how to access Raspberry Camera in Java? I am creating an Application using swing, currently running on Desktop accessing Webcam to show video stream.

Any suggestion how it could be done using Raspberry Camera?
I would have suggested starting a seperate thread since your request has very little to do with the subject...
but: viewtopic.php?f=81&t=130644

Re: Integrating NetBeans for Raspberry Pi Java Development

Posted: Sun Oct 09, 2016 6:06 am
by jingram
The approach is based on Netbeans capability and only if you Netbeans project is using the Ant build system.

Most Java projects these days try to be agnostic to the IDE using build systems such as Maven.
You can now achieve the remote execution on you Pi as follows:

If you have a Maven based project you can switch out the Maven Exec plugin with a SSH Exec plugin.
https://bitbucket.org/jingram/ssh-maven-plugin/overview

The plugin will automatically connect via SSH to the pi given the host, port and username / password credentials.
It will then automatically upload the Maven project dependences (all those JARs your project requires) and then execute the Java project as a remote Java process on the Pi.

You can also attach a debugger to the remote process for debugging in your IDE.

To enable this in Netbeans, add the following plugin to your pom.xml replacing the configuration with your own.

<build>
<plugins>
<plugin>
<groupId>org.rogueware.mojo</groupId>
<artifactId>ssh-exec-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<sshHost>10.0.0.1</sshHost>
<sshUsername>pi</sshUsername>
<sshPassword>raspberry</sshPassword>
</configuration>
</plugin>
</plugins>
</build>

In Netbeans, replace the Maven actions to use the ssh exec instead of the standard org.codehaus.mojo exec as follows:

Right click on the Maven project in the Projects tab
Select Properties
Click on Actions
Select "Run project" in the actions list
Replace "org.codehaus.mojo:exec-maven-plugin:1.2.1:exec" with "org.rogueware.mojo:ssh-exec-maven-plugin:1.0:exec" in the Execute Goals
Select "Debug project" in the actions list
Replace "org.codehaus.mojo:exec-maven-plugin:1.2.1:exec" with "org.rogueware.mojo:ssh-exec-maven-plugin:1.0:exec" in the Execute Goals

Re: STICKY: Integrating NetBeans for RPi Java Development

Posted: Fri Oct 20, 2017 7:51 am
by adamlee
Integrating NetBeans for RPi java devlopment. its a hard thing.
http://www.traininginmarathahalli.in/ja ... bangalore/

Re: STICKY: Integrating NetBeans for RPi Java Development

Posted: Thu Nov 02, 2017 5:21 pm
by crosland
I have read this thread and the JavaSEEmbeddedHowTo. I can create a remote platform and successfully test it. When I open the project properties, however, I cannot see the options to set the runtime platform. I see a combined "build & run" that apperas as:
Capture.PNG
Capture.PNG (18.2 KiB) Viewed 19075 times
Is this because the project (JMRI) uses a custom build script?

Can anyone suggest a way around this?

I can build on the Pi but it's painfully slow so I want to build on my desktop and deply remotely.

Andrew