Oracle by Example brandingQuick Start Tutorial Using a Java Application

section 0Before 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?


section 1Configure Your Simulated Device

  1. Download the latest version of the Java SE Client Software Library binaries file from the Oracle Technologies Network downloads page.
  2. Open a command-line interface and go to the directory where you downloaded your library.
  3. Extract the iotcs-csl-javase-bin-release.zip file, where release is the release and version number.
    unzip iotcs-csl-javase-bin-release.zip
  4. Verify the following subdirectories are listed under the iotcs\csl\javase directory:
    • bin
    • lib

section 2Send Your First Message

  1. Open a command-line interface and change directories to iotcs\csl\javase.
  2. In the iotcs\csl\javase directory, create a directory named samples\HelloWorld.
  3. In the iotcs\csl\javase\samples\HelloWorld directory, download the HelloWorld.java file.
  4. Compile the Java class using the following command:
    javac -cp ../../lib/device-library.jar HelloWorld.java 
  5. Verify that your class was successfully compiled by checking that the iotcs\csl\javase\samples\HelloWorld directory contains the HelloWorld.class file.
  6. 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.
  7. 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

section 3Verify Your Message

  1. Sign in to your Oracle IoT Cloud Service instance.
  2. 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.
  3. Find your message in the Messages table and review the value of Message Content.
    Messages table
    Description of the illustration messages_table.png

more informationWant to Learn More?