This repository is used in conjunction with the Cloudinary training course Introduction to Cloudinary Using Java.
The Cloudinary Java SDK will run on Java 6 and any higher version. For purposes of training, we are using Java Version 8.
The Cloudinary libraries are made available with Maven. This repo includes a project configured with Cloudinary libraries.
We are supplying a pom.xml
file. You'll find these dependencies have been added to support this training.
- com.cloudinary.cloudinary-taglib produce custom tags
- com.cloudinary-http44 Apache 4.4 integration
- com.google.code.gson format JSON output
- junit testing
See Cloudinary Documentation on Maven for more information about Cloudinary Maven libraries.
For many IDE's like Visual Studio Code, you won't need to install Maven. They will take care of importing the library and plugin dependencies.
We present this content using IntelliJ IDEA or Java in Visual Studio Code.
You may import the Java code used into your favorite IDE. You'll find the Main.java
in repo in the folder src/main/java/cld_intro_java/
. This is the entry point to static "runners" that contain code to help you upload, manage and transform your media.
You can find instructions for downloading and installing Java for many environments.
java -version
Sample output for Version 8
$ java -version
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)
You will need to register for a free Cloudinary account in order to work along with this training. It is recommended that you create a training account for this training to keep this work separate from any work you do in a production Cloudinary account. You only need an email address that can be verified to set up this account.
Cloudinary provides 3 credentials for developers to use in interacting with SDK's and Widgets:
- CLOUD_NAME
- API_KEY
- API_SECRET
CLOUD_NAME and API_KEY can be revealed without creating any security issues, but you must keep API_SECRET private. Don't check it into GitHub and don't include it in blog posts.
Cloudinary provides CLOUDINARY_URL as an environment variable KEY. You can copy the full value in your console. Click on the Copy to Clipboard
link to copy the full URL into your clipboard. The format of the CLOUDINARY_URL is cloudinary://API_KEY:API_SECRET@CLOUD_NAME
. This environment variable, therefore, encapsulates all of the Cloudinary credentials.
Edit Configuration
Add Environment Variables
Add Java Extension pack to your VS Code installation: Java Extensions for VS Code.
Add CLOUDINARY_URL to a .env
key in the .vscode/launch.json
. We have git ignored .vscode
, so your API_SECRET will not get checked in.
You will see run | debug
links above the main method in main.java
. Click run to execute.
The Cloudinary library is instantiated with credentials in src/main/java/cld_intro_java/Main.java
. Code in the other module files is called with a static runner
function.
Map results are formatted in the console using a static function in src/main/java/cld_into_java/CourseUtils.java
named jsonPrint
. This function takes a Map
interface parameter and uses the com.google.gson.GsonBuilder
library to "pretty print" the data as JSON.
You will be controlling output by uncommenting modules in Main.java
and lines of code in the other java files. This is to provide focus on concepts as they are presented.
All local assets used in training, are located in the ./assets
directory