The way to install Java depends of your OS or Linux distribution. At the Cytomine team, we use the OpenJDK versions.
For example, on Ubuntu, you can install java with the following command:
sudo apt-get install openjdk-8-jre
As Java is a compiled language, we will download the jar file of the latest version of the Cytomine-java-client. All of these versions can be found here.
Currently, the last version is the 1.9.9.
In the terminal, you can download it with the following command:
wget https://github.com/cytomine/Cytomine-java-client/releases/download/v1.9.9/cytomine-java-client.jar -O lib/cytomine-java-client.jar
You can already use the Java client as a library into your Java program, however we will test it by writing a simple groovy script.
If groovy is not installed, run the commands into a terminal
curl -s get.sdkman.io | bash
follow the instructions displayed then run the commands
export JAVA_HOME="$(dirname $(dirname $(which java)))" sdk install groovy
Then create a test.groovy file with the following content and replace the The_instance_URL, Your_public_key and Your_private_key variables by the correct values related to an instance of Cytomine (our keys can be founded in https://doc.cytomine.org/Get Started V2?structure=UsersV2" class="wiki wikinew text-danger tips">your account setting.
import be.cytomine.client.*; import be.cytomine.client.collections.*; import be.cytomine.client.models.*; String cytomineCoreUrl = The_instance_URL; String publickey = Your_public_key; String privatekey = Your_private_key; Cytomine.connection(cytomineCoreUrl, publickey, privatekey); println Cytomine.getInstance().getCurrentUser().get("username") //end
This code establish a connection with a Cytomine instance determined by its url and print the username of the connected user (the user that have these public and private keys).
Run it with the command:
groovy -cp cytomine-java-client.jar test.groovy
Note that we suppose that the downloaded cytomine-java-client.jar is in the same folder than the file test.groovy. If not, reference the jar file with an absolute or the appropriate relative path.
As a result, your Cytomine username will be printed on the terminal.
Once you got the main concept of all the External clients, you can take a look at the examples (and also the tests) that use the java client for various interaction with a Cytomine instance (interaction with annotations, add a new user, get images, etc.).