The CAP Java SDK enables developing CAP applications in Java. While the SAP Business Application Studio provides excellent support to develop CAP Java applications, you can also develop locally with your tool of choice, for example Eclipse or Visual Studio Code.
The CAP Java SDK supports lean application design by its modular architecture, that means you pick the required features and add them to your application dependencies on demand.
It enables local development by supporting in-memory or file-based SQLite databases. At the same time, the CAP Java SDK enables switching to a productive environment, using, for example, SAP HANA as a database, easily by simply switching the application deployment configuration.
If you use Spring Boot, you find yourself directly at home when using the CAP Java SDK, as the framework integrates with Spring Boot features like transaction handling, auto-wiring and test support. While the CAP Java SDK is framework agnostic, it's also possible to develop plain Java applications or even integrate with other frameworks.
The CAP Java SDK comes with an OData V4 protocol adapter, but it's openly designed. You can add more protocol adapters in the future or provide even custom protocol adapters by the application.
It supports SAP BTP features like authentication and authorization based on XSUAA tokens. But you aren't locked in to SAP BTP using a CAP Java application.
Excited? The following sections describe how to set up a development environment to get you started.
Execute the following commands on the command line to check whether the installed tools are set up correctly:
For a preconfigured environment, use SAP Business Application Studio, which comes with all of the required tools preinstalled. In older workspaces it might be necessary to explicitly set the JDK to version 17 with the command Java: Set Default JDK.
When prompted, specify the group ID and artifact ID of your application. The artifact ID also specifies the name of your projects root folder that is generated in your current working directory. For other values prompted, it's enough to simply confirm the default values.
Alternatively, you can use the CDS tools to bootstrap a Java project:
You can call cds help init for more information on the available options.
Following the "Grow As You Go" principle, the generated CAP Java project doesn't contain support for Cloud Foundry as the target platform. To enhance your project with dependencies required for Cloud Foundry, execute the goal addTargetPlatform of the CDS Maven plugin using the following command:
Optionally, you can use the CDS Maven plugin to enhance your CAP Java application with an additional Maven module to perform integration tests. To add such a module, go into the root folder of your CAP Java project and execute the following Maven command:
Install the Spring Tools 4 Eclipse plugin, that makes development of Spring applications more convenient. From the Eclipse Marketplace (Help > Eclipse Marketplace...), search and install Spring Tools 4.
Add the SAP Cloud Business Application Tools for Eclipse
Install the Eclipse plugin called SAP Cloud Business Application Tools for Eclipse that supports convenient editing of CDS files.
Select your PROJECT-ROOT folder and click Go. Finally, select the project that was found.
To not be distracted by CDS tools-specific folders in Eclipse, you can define resource filters. Open the context menu on the project's root folder and select "Properties". Go to Resource > Resource Filters and exclude folders with the name node_modules.