SDK for Java Cloud Shell Quick Start

This quick start shows you how to quickly get started running sample code with the Oracle Cloud Infrastructure SDK for Java using Cloud Shell.

This quick start shows you how to quickly get started running sample code with the Oracle Cloud Infrastructure SDK for Java using Cloud Shell.

  1. Login to the Console.
  2. Click the Cloud Shell icon in the Console header. Note Cloud Shell will execute commands against the region selected in the Console's Region selection menu when Cloud Shell was started.
  3. Create a working directory and move to it:
    mkdir java_demo
    cd java_demo
  4. Copy a pre-installed example (also available from github) from the OCI Java SDK examples/ folder to your working directory:
    cp $OCI_JAVA_SDK_LOCATION/examples/ListDBVersionExample.java .
  5. Compile the example:
    javac -cp .:$OCI_JAVA_SDK_FULL_JAR_LOCATION:$OCI_JAVA_SDK_LOCATION/third-party/lib/*:$OCI_JAVA_SDK_LOCATION/lib/jersey/*:$OCI_JAVA_SDK_LOCATION/third-party/jersey/lib/* ListDBVersionExample.java
  6. Run the example:
    java -cp .:$OCI_JAVA_SDK_FULL_JAR_LOCATION:$OCI_JAVA_SDK_LOCATION/third-party/lib/*:$OCI_JAVA_SDK_LOCATION/lib/jersey/*:$OCI_JAVA_SDK_LOCATION/third-party/jersey/lib/* ListDBVersionExample $OCI_TENANCY BM.HighIO1.36
    This will return output similar to the following:
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    DB Versions Fetched for Shape ocid1.tenancy.oc1..aaaaaaaayexample and compartment ocid: BM.HighIO1.36
    [DbVersionSummary(version=11.2.0.4, isLatestForMajorVersion=true, supportsPdb=false, isPreviewDbVersion=false, isUpgradeSupported=false, __explicitlySet__=[isPreviewDbVersion, 
    isUpgradeSupported, isLatestForMajorVersion, version, supportsPdb]), DbVersionSummary(version=12.1.0.2, isLatestForMajorVersion=true, supportsPdb=true, isPreviewDbVersion=false, 
    isUpgradeSupported=false, __explicitlySet__=[isPreviewDbVersion, isUpgradeSupported, isLatestForMajorVersion, version, supportsPdb]), DbVersionSummary(version=12.2.0.1, 
    isLatestForMajorVersion=true, supportsPdb=true, isPreviewDbVersion=false, isUpgradeSupported=false, __explicitlySet__=[isPreviewDbVersion, isUpgradeSupported, 
    isLatestForMajorVersion, version, supportsPdb]), DbVersionSummary(version=18.0.0.0, isLatestForMajorVersion=true, supportsPdb=true, isPreviewDbVersion=false, 
    isUpgradeSupported=false, __explicitlySet__=[isPreviewDbVersion, isUpgradeSupported, isLatestForMajorVersion, version, supportsPdb]), DbVersionSummary(version=19.0.0.0, 
    isLatestForMajorVersion=true, supportsPdb=true, isPreviewDbVersion=false, isUpgradeSupported=true, __explicitlySet__=[isPreviewDbVersion, isUpgradeSupported, isLatestForMajorVersion, 
    version, supportsPdb]), DbVersionSummary(version=21.0.0.0, isLatestForMajorVersion=true, supportsPdb=true, isPreviewDbVersion=false, isUpgradeSupported=false, 
    __explicitlySet__=[isPreviewDbVersion, isUpgradeSupported, isLatestForMajorVersion, version, supportsPdb])]