Before You Begin
This 15-minute tutorial shows you how to build a Java application that simulates a virtual device and sends a message to Oracle Internet of Things (IoT) Cloud Service.
Background
Oracle IoT Cloud Service provides communication services between devices and enterprise applications. In this tutorial, you build a simulated device in a Java application, and then transmit a Hello World message to Oracle IoT Cloud Service.
What Do You Need?
- Access to an Oracle IoT Cloud Service instance
- A computer running Windows 7, Mac OS 10.9 or later, or Linux with a web browser and a recent version of Java Development Kit (JDK)
- Installed software:
- Java Standard Edition Development Kit (Java SE JDK) 6.0 or later
- Oracle Client Software Library for Java
- The
HelloWorld.java
file - A file compression tool
- Good knowledge of Java, basic knowledge of command-line tools. For information on how to correctly configure your Java Environment, see Setting Up Your Java SE Development Environment to Use Oracle IoT Cloud Service Client Software Libraries
- Complete the following tutorial: Configuring an Application in Oracle Internet of Things Cloud Service
Configure Your Simulated Device
- Download the latest version of the Java SE Client Software Library binaries file from the Oracle Technologies Network downloads page.
- Open a command-line interface and go to the directory where you downloaded your library.
- Extract the
iotcs-csl-javase-bin-release.zip
file, whererelease
is the release and version number.unzip iotcs-csl-javase-bin-release.zip
- Verify the following subdirectories are listed under the
iotcs\csl\javase
directory:bin
lib
Send Your First Message
- Open a command-line interface and change directories to
iotcs\csl\javase.
- In the
iotcs\csl\javase
directory, create a directory namedsamples\HelloWorld.
- In the
iotcs\csl\javase\samples\HelloWorld
directory, download theHelloWorld.java
file. - Compile the Java class using the following command:
javac -cp ../../lib/device-library.jar HelloWorld.java
- Verify that your class was successfully compiled by checking that the
iotcs\csl\javase\samples\HelloWorld
directory contains theHelloWorld.class
file. - Locate the provisioning file that you downloaded when you registered the device in the Configuring an Application in Oracle Internet of Things Cloud Service tutorial, and copy it into the
iotcs\csl\javase\samples\HelloWorld
directory. - Send your first message. In the example, replace
File_Protection_Password
with the configuration data value that you obtained in the Configuring an Application in Oracle Internet of Things Cloud Service tutorial.java -cp .;../../lib/device-library.jar;../../lib/jsjson-20200518.jar HelloWorld ProvisioningFile File_Protection_Password
Verify Your Message
- Sign in to your Oracle IoT Cloud Service instance.
- In the Oracle IoT Cloud Service Management Console, navigate to the Oracle IoT Asset Monitoring application, select Data, and then in Filter By, select Device.
- Find your message in the Messages table and review the value of Message Content.
Description of the illustration messages_table.png