Commit 3fe0960f authored by Martin Deinhofer's avatar Martin Deinhofer
Browse files
parents 80cf4330 fed68b9f
# 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](https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html).
# 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"](https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html)) **or**
* Cygwin or MinGW on Windows ([Read "How to Setup Cygwin and MinGW](https://www3.ntu.edu.sg/home/ehchua/programming/howto/Cygwin_HowTo.html)
# Clone project
```git clone https://es.technikum-wien.at/embedded_systems_public/Java-Exercises-7-JNI-HW-Interfacing.git```
See [Remote Development Setup](RemoteDev-Setup.md) tutorial.
# Build project
Building the project involves two steps
1. Building Java code
2. Building native code
These tasks are done in the makefile, so call:
1. Connect to the remote device
2. Build Java + native code on command line
```cd jni && make```
# Run project
......@@ -29,12 +19,4 @@ This can be done via the VM argument ```-Djava.library.path```.
## Command line
```java -cp bin -Djava.library.path=jni java_exercises8_1_1.HelloJNI```
or using the makefile
```cd jni && make run```
```java -Djava.library.path=jni -cp bin java_exercises8_1_1.HelloJNI```
\ No newline at end of file
# 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)](http://www.raspberrypi.org/) (2xUSB, HDMI (Video and Audio), SD-Card, LAN, Analogue Video,
Analogue Audio)
* Wifi-Dongle
* [PiFace Digital I/O](http://www.piface.org.uk/products/piface_digital/) (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)](http://www.raspberrypi.org/) (4xUSB, HDMI (Video and Audio), Micro-SD-Card, LAN, Analogue
Audio)
* [Control & Display 2](http://www.piface.org.uk/products/piface_control_and_display/) (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](https://www.raspberrypi.org/downloads/raspbian/)
* JDK8 (OpenJDK or [Oracle JDK 8 for ARM](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html), **not JDK 11**)
* C-Compiler, Makefile support
## Installation Setups
1. [Download and install](https://www.raspberrypi.org/documentation/installation/) image to SD card.
2. Assemble HW
1. Wifi
2. Attach Control&Display add-on board
3. HDMI
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 your add-on board with Python:
1. [Install PiFace Digital I/O](http://www.piface.org.uk/guides/Install_PiFace_Software/)
1. [Install PiFace C&D](http://www.piface.org.uk/guides/setting_up_pifacecad/fitting_PiFace_Control_and_Display/)
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](https://www.raspberrypi.org/documentation/remote-access/)
1. Enable SSH
7. Configure Development Environment
You can **either** directly edit the source code locally on the RPi **or** edit it remotely through ssh or samba. Choose the preferred setup for you:
### Local on RPi
Visual Studio Code supports ARM devices and can directly be installed on a Raspberry Pi, depending on the RPi model this can be slow, but with RPi3 and newer models it should be ok.
Please read the [tutorial for Visual Studio Code installation on an RPi](https://pimylifeup.com/raspberry-pi-visual-studio-code/).
### Remote from PC/Laptop
You can use an IDE of choice on your 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](https://visualstudio.microsoft.com/services/live-share/?rr=https%3A%2F%2Fwww.google.com%2F) and remote development on a linux machine or container.
### Visual Studio Code
Visual Studio Code provides a Remote Development Environment using SSH to connect to a Linux machine (e.g. Raspberry Pi with SSH enabled).
You will need Visual Studio with [Java IDE Pack](https://marketplace.visualstudio.com/items?itemName=pverest.java-ide-pack) and [Remote Development Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack).
Please read the [tutorial for remote development with SSH](https://code.visualstudio.com/docs/remote/ssh).
### Eclipse with remote system explorer
Eclipse supports remote code editing, but with no IntelliSense support.
You will need Eclipse with Java language support and [Remote System Explorer extension](https://marketplace.eclipse.org/content/remote-system-explorer-ssh-telnet-ftp-and-dstore-protocols#group-details)
### IntelliJ IDEA
IntelliJ idea does not have direct remote development support, but IntelliJ IDEA can be used for remote editing if the source code on the remote machine is made accessible by samba share.
You can then open the source code project on the network share and edit the code as if it was local.
Have a look at the [Samba/CIFS raspberry pi tutorial](https://www.raspberrypi.org/documentation/remote-access/samba.md).
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