This document describes how to prepare your development environment to use the Microsoft Azure IoT Gateway SDK for Java module development.
## Install Java JDK SE To use the SDK and run the samples you will need a **32-bit** installation of a **JDK** (it is insufficient to only have the JRE installed).For downloads and installation instructions go here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Please make sure that the
JAVA_HOME
environment variable includes the full path to thejdk1.x.x
directory. (Example: JAVA_HOME=C:\Program Files\Java\jdk1.8.0_92) - Please make sure that the
PATH
environment variable includes the full path to thejdk1.x.x\jre\bin
directory. (Example: %JAVA_HOME%\bin) - Please make sure that the
PATH
environment variable includes the full path to thejdk1.x.x\jre\bin\server
directory. (Example: %JAVA_HOME%\jre\bin\server)
You can test whether your PATH
variable is set correctly by restarting your console and running java -version
.
Depending on your Linux distribution, you can install the JDK using apt-get, alternatively, you may visit the link above to find the download and instructions for Linux x86.
-
Please make sure that the
PATH
environment variable includes the full path to the bin folder containing java as well as the server directory containing the jvm.which java echo $PATH
Ensure that the bin directory shown by the
which java
command matches one of the directories shown in your $PATH variable and that the server directory containing the jvm is present in your $PATH. If it is not:export PATH=/path/to/java/bin:$PATH export PATH=/path/to/java/jre/lib/amd64/server:$PATH
-
Please make sure that the
JAVA_HOME
environment variable includes the full path to the jdk.update-alternatives --config java
Take note of the jdk location.
update-alternatives
will show something similar to /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java. The jdk directory would then be /usr/lib/jvm/java-8-openjdk-amd64/.export JAVA_HOME=/path/to/jdk
For downloads and installation instructions go here: https://maven.apache.org/download.cgi
- Please make sure that the
PATH
environment variable includes the full path to theapache-maven-3.x.x\bin
directory. (Example: F:\Setups\apache-maven-3.3.3\bin). Theapache-maven-3.x.x
directory is where Maven 3 is installed.
You can verify that the environment variables necessary to run Maven 3 have been set correctly by restarting your console and running mvn --version
.
On Linux, Maven 3 can be installed as follows:
sudo apt-get update
sudo apt-get install maven
Please verify the following:
Ensure the PATH
environment variable contains the full path to the bin folder containing Maven 3.
which mvn
echo $PATH
Ensure that the bin directory shown by the which mvn
command matches one of the directories shown in your $PATH variable.
If it does not:
export PATH=/path/to/mvn/bin:$PATH
You can verify that the environment variables necessary to run Maven 3 have been set correctly by running mvn --version
.
- There are two ways to get the .jar library for the Java module binding for the Microsoft Azure IoT Gateway SDK. You may either download the source code and build on your machine, or include the project as a dependency in your project if your project is a Maven project. Both methods are described below.
Open a command prompt and use the following commands for the steps above:
git clone https://github.com/Azure/azure-iot-gateway-sdk.git
cd azure-iot-gateway-sdk/bindings/java/gateway-java-binding
mvn clean install
The compiled JAR file with all dependencies bundled in can then be found at:
{IoT gateway SDK root}/bindings/java/gateway-java-binding/target/gateway-java-binding-{version}.jar
When you're ready to build your own module in Java, include this JAR file in your project to get the interfaces and classes that you need.
## Sample applicationsThis repository contains a sample gateway that includes modules written in Java that illustrate how to write modules in Java and use the Microsoft Azure IoT Gateway SDK. For more information, see the readme.