sr29067
Posts: 7
Joined: Thu Jan 26, 2012 4:42 pm

STICKY: Integrating NetBeans for RPi Java Development

Wed Oct 30, 2013 12:48 pm

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.

Zerjillo
Posts: 2
Joined: Tue Feb 07, 2012 11:44 pm
Contact: Website

Re: Integrating NetBeans for Raspberry Pi Java Development

Thu Nov 14, 2013 10:29 am

Thank you very much!

suipaste
Posts: 17
Joined: Tue Jul 17, 2012 6:50 pm

Re: Integrating NetBeans for Raspberry Pi Java Development

Wed Jan 08, 2014 3:42 pm

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

User avatar
topguy
Posts: 3295
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Integrating NetBeans for Raspberry Pi Java Development

Wed Jan 08, 2014 3:58 pm

Code: Select all

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

suipaste
Posts: 17
Joined: Tue Jul 17, 2012 6:50 pm

Re: Integrating NetBeans for Raspberry Pi Java Development

Wed Jan 08, 2014 4:15 pm

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?

DBryant
Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: Integrating NetBeans for Raspberry Pi Java Development

Wed Jan 08, 2014 4:30 pm

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

Fidelius
Posts: 394
Joined: Wed Jan 01, 2014 8:40 pm

Re: Integrating NetBeans for Raspberry Pi Java Development

Thu Feb 06, 2014 8:08 pm

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.

Mike08
Posts: 11
Joined: Fri Nov 21, 2014 5:56 am

Re: Integrating NetBeans for Raspberry Pi Java Development

Fri Nov 21, 2014 6:34 am

Can a java application in windows could run in raspberry pi through LAN?

User avatar
DougieLawson
Posts: 28807
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Integrating NetBeans for Raspberry Pi Java Development

Fri Nov 21, 2014 8:04 am

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.)
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

Fidelius
Posts: 394
Joined: Wed Jan 01, 2014 8:40 pm

Re: Integrating NetBeans for Raspberry Pi Java Development

Fri Nov 21, 2014 8:16 am

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. :-)

Mike08
Posts: 11
Joined: Fri Nov 21, 2014 5:56 am

Re: Integrating NetBeans for Raspberry Pi Java Development

Fri Nov 21, 2014 5:42 pm

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.

Fidelius
Posts: 394
Joined: Wed Jan 01, 2014 8:40 pm

Re: Integrating NetBeans for Raspberry Pi Java Development

Fri Nov 21, 2014 7:37 pm

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.

Mike08
Posts: 11
Joined: Fri Nov 21, 2014 5:56 am

Re: Integrating NetBeans for Raspberry Pi Java Development

Sat Nov 22, 2014 3:43 am

Okay thanks for the help.. If everything goes wrong can i consult you again?

Mike08
Posts: 11
Joined: Fri Nov 21, 2014 5:56 am

Re: Integrating NetBeans for Raspberry Pi Java Development

Sat Nov 22, 2014 3:46 am

What about the connection of the Pi and my computer?
Can LAN will do?
or Wifi connectivity?

Fidelius
Posts: 394
Joined: Wed Jan 01, 2014 8:40 pm

Re: Integrating NetBeans for Raspberry Pi Java Development

Sat Nov 22, 2014 9:29 am

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.

Mike08
Posts: 11
Joined: Fri Nov 21, 2014 5:56 am

Re: Integrating NetBeans for Raspberry Pi Java Development

Sun Nov 23, 2014 3:37 am

Okay,, thanks for the help.. :)

boneoh
Posts: 5
Joined: Thu Jan 15, 2015 11:41 pm

Re: Integrating NetBeans for Raspberry Pi Java Development

Thu Jan 15, 2015 11:50 pm

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

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: Integrating NetBeans for Raspberry Pi Java Development

Thu Feb 12, 2015 12:49 pm

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

User avatar
Nitrogen
Posts: 7
Joined: Mon Jul 09, 2012 9:18 am
Location: Ukraine, Kryvyi Rih

Re: Integrating NetBeans for Raspberry Pi Java Development

Sat Apr 18, 2015 11:40 am

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
Raspberry Pi Model B
Linux raspberrypi 3.18.4+ #743 PREEMPT Wed Jan 28 17:14:53 GMT 2015 armv6l GNU/Linux

vikbaba
Posts: 1
Joined: Thu Apr 21, 2016 5:39 am

Re: Integrating NetBeans for Raspberry Pi Java Development

Thu Apr 21, 2016 5:43 am

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?

User avatar
topguy
Posts: 3295
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Integrating NetBeans for Raspberry Pi Java Development

Thu Apr 21, 2016 10:19 am

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

jingram
Posts: 2
Joined: Sun Oct 09, 2016 5:54 am

Re: Integrating NetBeans for Raspberry Pi Java Development

Sun Oct 09, 2016 6:06 am

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

Return to “Java”

Who is online

Users browsing this forum: No registered users and 4 guests