Commit d8b411ad authored by Martin Deinhofer's avatar Martin Deinhofer
Browse files

Fixed and added tutorial for remote development setup

parent dafca4c1
# Exercise repository for Java Native Interface (JNI)
At times, it is necessary to use native codes (C/C++) to overcome the memory management and performance constraints in Java. Java supports native codes via the Java Native Interface (JNI). This repository contains a "Hello World" example for using the JNI which is based on this [tutorial](
# Repository for Raspberry Pi + PiFace Control & Display
# Prerequisites
1. **Java Development Kit 8**
2. **C/C++ Compiler**
* GCC compiler and Makefile ([Read "GCC and Make"]( **or**
* Cygwin or MinGW on Windows ([Read "How to Setup Cygwin and MinGW](
3. **Eclipse for Java Developers** with **C/C++ Development Tool (CDT) extension** installed ([Read "Eclipse CDT"](
# Clone project
```git clone```
# Create Eclipse project
1. *File/New/Project*
2. Select *General/Project* and click *Next*
3. Unselect *Use default location* and browse to cloned diretory, click *OK*
4. Enter *Project name* and click *Finish*
See [Remote Development Setup]( tutorial.
# Build project
Building the project involves two steps
1. Building Java code
* Click on *Project/Build All*. This is not necessary if *Build Automatically* is selected.
2. Building native code either on command line or using the configured Eclipse build targets
* Command line:```cd jni && make``` or
* Double click on *jni/Build Targets/all*
1. Connect to the remote device
2. Build native code on command line
* Command line:```cd jni && make```
# Run project
Before the application can be run, you must build the native code and provide the library path to the "hello.dll" file, if it is not located in the *current working directory*.
This can be done via the VM argument ```-Djava.library.path```. Right-click on the project and select *Run As/Run Configurations*, then select *Java Application*. In the *Main tab*, enter the main class "HelloJNI" and in *Arguments/VM Arguments*, enter ```-Djava.library.path=jni```. Finally click on *Run*.
You should see the output "Hello World!" displayed on the console.
This can be done via the VM argument ```-Djava.library.path```.
## Command line
```java -Djava.library.path=jni -cp bin java_exercises7_1_1.HelloJNI```
```java -Djava.library.path=jni -cp bin java_exercises8_1_1.HelloJNI```
# Java + Raspberry Pi Remote Development Setup
The objective of the tutorial is to install and setup the Raspberry Pi as an Embedded Development Platform for the Java Standard Edition 8 or Java Standard Edition 8 Embedded.
![Archtecture of the Remote Development Setup: Both Raspberry Pi and Development Host are connected using a Wifi hotspot](./Java_Embedded_Dev_Architecture.png)
## HW-Requirements
There are two different sets of hardware.
### Set One
* [Raspberry Pi (Model B+, or 2)]( (2xUSB, HDMI (Video and Audio), SD-Card, LAN, Analogue Video,
Analogue Audio)
* Wifi-Dongle
* [PiFace Digital I/O]( (2 Changeover Relays, 4 Tactile Switches, 8 Digital Inputs, 8 Open-Collector Outputs, 8 LED Indicators)
* Cables: HDMI, USB -> USB Micro
### Set Two
* [Raspberry Pi (Model B+, or 2)]( (4xUSB, HDMI (Video and Audio), Micro-SD-Card, LAN, Analogue
* [Control & Display 2]( (2x16 character alphanumeric display, IR receiver, 3-position
switch, 5 tactile switches)
* Wifi-Dongle
* Cables: HDMI, USB -> USB Micro
Additionally, you will need a keyboard and a mouse for initial setup.
## SW-Requirements
### Raspbian
* [Linux image Raspbian](
* JDK8 ([OpenJDK]() or [Oracle JDK 8 for ARM](, **not JDK 11**)
* C-Compiler, Makefile support
## Installation Setups
1. [Download and install]( image to SD card.
2. Assemble HW
1. Wifi
2. Attach Control&Display add-on board
4. Power
5. Keyboard
3. Boot locally+display+keyboard+mouse
4. Test add-on board
PiFace uses the SPI bus of the Raspberry Pi, which is disabled by default, so you must enable it. Enable SPI and test the add-on board with Python:
1. [Install PiFace Digital I/O](
1. [Install PiFace C&D](
5. Install and test Java Development Kit 8
sudo apt-get update && sudo apt-get install openjdk-8-jdk
javac -version
7. Install C-compiler
6. Configure [Remote Access](
1. Enable SSH
7. Configure Remote Development.
You can use an IDE of choice on your host PC to connect to the Raspberry Pi remotely via SSH. Visual Studio Code is recommended as it supports collaborative development using [Visual Studio Live Share](
1. Visual Studio with [Java Extension Pack]( and [Remote Development Extension Pack](
1. Eclipse with Java language support and [Remote System Explorer extension](
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment