Scratch4J is a Java library for interacting with the scratch.mit.edu website.
Logging into an account
Scratch4j scratch4j = new Scratch4j();
ScratchSession session = scratch4j.login("Username", "Password");
Connecting to a project's cloud server and changing a variable
ScratchCloudSession cloudSession = session.startCloudSession(projectid);
cloudSession.setVariable("variable", "123");
Listening for cloud variable changes
cloudSession.addListener(event -> {
System.out.println(event.getVariable() + " was changed to " + event.getValue());
});