Skip to Content
Technical Articles

Setting Up the Development Environment – Eclipse , Java, Maven, SAP CAP ,Cloud Tools for SAP Cloud Application Programming Model

Introduction

As explained in Capire documentation  you can efficiently and rapidly build enterprise services and business applications in a full-stack development approach & and extend S/4HANA  with your own choice of Tools ,your comfortable code Editors using SAP Cloud Application Programming Model, Fiori and Java or Node.js.

For a preconfigured development environment, use SAP Business Application Studio which comes with all of the required tools preinstalled. Just highlighting few  tools hear i.e you no need to install most of tools if your going to use SAP Business Application Studio

However SAP Cloud Application Programming model (CAP)  provides world-class support for developing based enterprise applications, whether you prefer SAP Business Application Studio (aka SAP WebIDE) , Eclipse, Visual Studio Code

Reference : https://cap.cloud.sap/docs/get-started/tools

 

  • SAP Business Application Studio

For a preconfigured/automated development environment, use SAP Business Application Studio, which comes with all of the required tools pre installed,which offers a modern development environment tailored for efficient development ,test ,debug ,deployment of business applications for the SAP Intelligent Enterprise
Read hear Blog post : https://blogs.sap.com/2020/09/28/sap-business-application-studio/

It’s time to try out SAP Business Application Studio


Onboarding/How to get it :Set Up SAP Business Application Studio for Development

# Click hear  for Tutorials/Exercises how to use SAP Business Application Studio 
  • Visual Studio Code
  • Eclipse

In this blog post we are going to learn “How to setup development environment if you are going to use Eclipse & JAVA to develop applications SAP Cloud Application Programming model (CAP) .

Reference  : https://cap.cloud.sap/docs/java/getting-started

 

Installation Guide Index

Prerequisites

This section describes the prerequisites required to build a CAP application locally, for example with Eclipse or Visual Studio Code or any Editor.


 

Step No Step Name Details
1 Node JS (LTS Latest Version ) & other CLI Tools https://nodejs.org/en/
Download Node JS (LTS Latest Version ) & other CLI Tools
Test (Optional) i.e Verify installation node -v
2 NPM Registry Configuration npm set @sap:registry=https://npm.sap.com
I,e Confirm installation
Test (Optional) I,e Confirm installation npm config list
3 Install SAP CDS SDK npm install -g @sap/cds-dk
Test (Optional) CDS  –version

Basic Setup

This section describes the prerequisites and tools required to build any kind of Java application Using Eclipse IDE (Step 4 to Step 7 )

Step No Step Name Details
4 Install Java Refer this document Step 4
5 Setup Maven Refer this  document Step 5
6 Install Eclipse for java Refer this   document Step 6
7 Install Spring Tools Refer this  document Step 7

Next install SAP CAP Support Tools for Eclipse IDE to develop application using CAP Java .

This software repository URL https://tools.hana.ondemand.com/2020-06 provides access to SAP Development Tools for Eclipse 2020-06 Release.

It is intended to be used in the Help > Install New Software wizard of Eclipse.

Using Eclipse IDE

Step No Step Name Details
8  Add the SAP Cloud Business Application Tools for Eclipse https://tools.hana.ondemand.com/2020-06

Advance Setup required for Cloud Foundry Environment of SAP Cloud Platform

Note :
>> This Advance installation steps are not mandatory to start your local development & deployment .You can stick to above basic setup (Step1 to Step 8)
>> If you are going to use SAP Business Application Studio then it is easy for your cloud application development ,test & deployment. You just need brower ,no need to install anything.
i.e setup is automated as explain above in Introduction section
>> If you have CI/CD pipeline then also you no need to setup "Advance section" for deployments to your dev space in cloud.

 

CAP applications can be deployed into the Cloud Foundry Environment of SAP Cloud Platform. At the end, it’s about deploying regular Node.js and/or Java applications, and about creating and binding appropriate service instances (see the CF Developer Guide).

https://cap.cloud.sap/docs/advanced/deploy-to-cloud

you can run below commands from command prompt

Step No Step Name Details
9 Chocolatey @”%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe” -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command “iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin” choco install -y nodejs-lts sqlite make curl jq cloudfoundry-cli
10 Install Windows Build Tools npm install –global windows-build-tools
11 Cloud Foundry CLI cf install-plugin multiapps
12 MTA plugin for the CF CLI. 1.Install the MTA Build Tool
https://sap.github.io/cloud-mta-build-tool/
  npm install -g mbt
Test (Optional) Sqlite3
 make
i.e Confirm installation cf
 curl
mbt

Let’s see above steps in detail

 

Step 1: Download & Install Node JS (LTS Version ) & other CLI Tools

 

https://nodejs.org/en/

 

For windows Machine download msi & then just double click

 

& Follow wizard for Installation

Here are Screenshots for your reference on how to install node js

 

 

 

Optional ,you can also install Chocolatey & other tools using npm/powershell scripts

 

 

Step 2 : NPM Registry Configuration for Command-Line and Build Tools

You can use the npm command to configure the SAP target registry for the current session:

Two options

  • Either using command prompt
  • Or manually edit .npmrc file

#1) Just run below command from command prompt

npm config set @sap:registry https://npm.sap.com

    #2) Alternatively you can also add below code in NPM Registry Configuration in the .npmrc File

@sap:registry=https://npm.sap.com

Location of file : C:\Users\xxxxxxxx

 

         Confirm installation (Optional step)

This step is just to verify whether configuration is correct or not.Just run from command prompt

          npm config list

Note : Resolving EACCES permissions errors when installing packages globally

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

Step 3: Setup CDS SDK

Open a command line window and install the cds development kit globally by executing the following command

npm i -g @sap/cds-dk

 

or

npm install –global @sap/cds-dk

Note :  

  • This process takes some minutes installing the cds command, which you will use in the next steps.
  • To verify that the installation was successful, run cds without arguments


Step 4 to Step 8 are specific to Ellipse and Java


Step 4: Install Java

You can install SAP supported version of OpenJDK for SAP customers and partners who wish to use OpenJDK to run their applications i.e SAP Machine which install JAVA which is close to JAVA OpenJDK/OracleJDK

Note: As an alternative option you can also use JAVA OpenJDK/Oracle JDK

Install a Java VM. At least, Java 8 is required.

For example, download and install SapMachine 11.

Download : https://github.com/SAP/SapMachine/releases/latest

Installation Steps : https://github.com/SAP/SapMachine/wiki/Installation

Steps to install SAP Machine (SAP JAVA) 

  1. Using the Windows Installer (download the MSI package) is the simplest way to install SapMachine on Windows.

        2) Just Double click or Run msi

3) Follow Wizard for installation (you can refer below screenshots)

 

  • Once you install Java, you need to set Environment variables

https://www.java.com/en/download/help/path.html

 

 

There are two choices as there are two types of environment variables: user environment variables (set only for current user) and system environment variables (set for all users).

The variable (ex: “%UserProfile%”) is used as a type of shortcut of the value (ex: “C:\Users\<username>”).

Just type System Environment Variables in Windows Search

In Windows in order to set

Step 1 : Right Click on MyComputer and click on properties .

Step 2 : Click on Advanced tab

Step 3: Click on Environment Variables

Or You can also go to Environment Variables from Windows Search,then Type “Edit the system environment variables ”

 

 

Verify Installation

Just run below command

java —version

Step 5: Install Maven

  • Go to (Maven Website à Use –> Download –> Download the Binary zip archive.)

Or click hear https://maven.apache.org/download.cgi

  • Download latest zip file
  •  After the download, unzip the folder and copy it to the folder. (Let’s say i have copied /extracted to location

                C:\Program Files\apache-maven-3.6.3

  • Add Path to System User Environment variables & System environment Variables

  Setting the path of Maven in environment Variables: Search the Environment    Variable –> Edit the System Environment variables–> Navigate to Advanced tab —   > Environment Variables

 

i) MAVEN_HOME :

 

Click New –>    Variable Name : MAVEN_HOME

Variable Value: C:\Program Files\apache-maven-3.6.3

 

ii) M2_HOME :Click New –> Variable Name : M2_HOME , Variable Value: C:\Program Files\apache-maven-3.5.2

iii) Edit the ‘Path’ Environment Variable –>

Update the PATH variable by appending the Maven bin folder – %M2_HOME%\bin, so that you can run the Maven’s command everywhere.

 

Testing whether Maven is installed:

Open command prompt & type

mvn -version

in the command prompt. It should display the Maven version, the java version, and the operating system information. That’s it, you have set up Maven on your Windows system

  • Verify Whether u already have .m2 folder in user directory

Just type %userprofile% in windows run to go to your user directory

 

This folder required for your to have all maven repositories

You have run “mvn package” command from command prompt

  • Configure Maven for the SAP build landscape by downloadingxml and save it to <USER_HOME>/.m2/settings.xml

Link : http://nexus.wdf.sap.corp:8081/nexus/service/local/templates/settings/LeanDI/content

Step 6: Install Eclipse

Install the Eclipse IDE for Enterprise Java developers.

https://www.eclipse.org/downloads/packages/release/2020-03/r/eclipse-ide-enterprise-java-developers-includes-incubating-components

 

Screenshots : Follow wizard as shown below

 

 

Next, select “Windows > Preferences” (PC) or “Eclipse > Preferences” (Mac) in the menu. Then, select “Java > Installed JREs”:

Step 7:  Add Spring Tools 4

 

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.

 

Step 8:  Install Eclipse Tools for SAP Cloud Application Programming Model

The Eclipse Tools for SAP Cloud Application Programming Model offer support for the Core Data Services (CDS) language and provide features to build, deploy and test business applications and services

Install the Eclipse plugin called SAP Cloud Business Application Tools for Eclipse that supports convenient editing of CDS files.

  • In Eclipse open Help > Install New Software….

Or

https://tools.hana.ondemand.com/2020-06

  • Select SAP Cloud Business Application ToolsSAP Cloud Business Application Tools for Eclipse.
  • Click Next and Finish, accept the license agreement and warning about unsigned content, restart Eclipse.

Note : Find additional information on the wiki pages for CDS Eclipse tools.

For SAP Cloud Application Programming Model in general see the documentation

Step 8.1 –> Install Additional SAP Development Tools for Eclipse Installation

Below is optional step not mandatory 

You can also follow below steps &  Install the additional SAP Development Tools for Eclipes

 

From the Eclipse menu, choose Help > Install New Software…
Add the URL of the tools update site for your Eclipse release, e.g: https://tools.hana.ondemand.com/2020-06
Then follow the steps of the installation wizard.

You can also install SAP HANA Tools ,SAP Modelling tools for Eclipse

For more information about the features see the embedded help

Reference :  development environment.

Below is optional step not related to SAP Cloud Application Programming Model

Troubleshooting Tips 

Typical error messages are:

>>No repository found at https://tools.hana.ondemand.com/ Eclipse Release Name
>>Could not find tools.hana.ondemand.com
>>Unable to connect to repository at  https://tools.hana.ondemand.com/ EclipseReleaseName

 

Probably, you did not configure the proxy correctly in Window > Preferences > General > Network Connections so that Eclipse can not reach https://tools.hana.ondemand.com. The correct proxy configuration depends on your IT infrastructure. The following 3 typical configurations have been reported as working in the support forum:

You can connect directly to the internet, i.e. don’t need any proxy.
Please configure ‘Direct’ as Active Provider.
You connect to the internet via http proxy.
Please configure ‘Manual’ as Active Provider and configure the proxy entries for the protocols HTTP and HTTPS. Do not configure anything for SOCKS.
You connect to the internet via SOCKS proxy.
Please configure ‘Manual’ as Active Provider and configure the proxy entry for the protocol SOCKS.

To find the right setup, you could check the proxy settings in your browser.

After fixing the proxy configuration, please go to Windows > Preferences > Install/Update > Available Software Sites, select e.g. the software site “SAP Development Tools for Eclipse Oxygen” and press ‘Reload’ to verify that the connection works now. Repeat the check for software site ‘Oxygen’ (http://download.eclipse.org/releases/oxygen).

Additional hints:

> On Windows, users experienced problems with the ‘Native’ proxy provider. Therefore, we recommend to use the ‘manual’ proxy provider and to configure the proxy settings manually.

> On the update site, there is no file https://tools.hana.ondemand.com/EclipseReleaseName/content.xml (even though Eclipse complains about it in the error message). If you want to test that you can download a file via browser, please test with https://tools.hana.ondemand.com/ <EclipseReleaseName>/content.jar (e.g. https://tools.hana.ondemand.com/oxygen/content.jar)

Please also test if you can install from the eclipse.org update site (https://download.eclipse.org/releases/<EclipseReleaseName>

  e.g. http://download.eclipse.org/releases/oxygen). If not, please check the proxy settings again.

In case your connection to the update site is very slow, you may run into timeouts (check the error message details). The following article helps to workaround the timeouts:

http://stackoverflow.com/questions/1489149/how-to-change-value-of-read-timeout-of-eclipses-update-manager

If this does not solve your problems then please request support in the SAP Cloud Platform Community .

Finally Verify the Setup

Execute the following commands on the command line to check whether the installed tools are setup correctly:

cds –version

java –version

mvn –version

 

 

Starting a New CAP JAVA based Project

 

Take the following steps to set up a new CAP Java application based on Spring Boot from scratch.

https://cap.cloud.sap/docs/get-started/

How to start new Java project

Reference: https://cap.cloud.sap/docs/java/getting-started

 

Two choices  you can generate new CAP JAVA project either using

  • CAP Java Maven Archetype

or

  • Using “CDS init “command

#1) Using the CAP Java Maven Archetype

Use the CAP Java Maven archetype, that is run behind the scenes of cds init, which allows to specify additional options: Screenshots for your reference 

mvn archetype:generate -DarchetypeArtifactId=cds-services-archetype -DarchetypeGroupId=com.sap.cds -DarchetypeVersion=RELEASE

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.

 

 

Then you can import project in Eclipse focus on modeling entities & writing services using CDS

  1. Open Eclipse , then Select File  menu > Import… > SAP Cloud Business Application.
  2. Select the xmlfile in your project and click Finish.

Example : If you need some example model or test cases , just add some additional parameters in above command 

 

mvn archetype:generate -DarchetypeArtifactId=cds-services-archetype -DarchetypeGroupId=com.sap.cds -DarchetypeVersion=RELEASE -DincludeModel=true -DincludeIntegrationTest=true

 

Explanation 

  • -DincludeModel=true: Adds a example sample CDS model to the project
  • -DincludeIntegrationTest=true: Adds an integration test module to the project

 

Project Layout

The generated project has the following folder structure:

<PROJECT-ROOT>/|– db/`– srv/    |– src/main/java/    |– src/gen/java/    |– node/    `– node_modules/

The generated folders have the following content:

  • db: Contains content related to your database i.e CDS models
  • srv: Contains the CDS service definitions and Java back-end code
  • srv/src/main/java: Contains Java application logic.
  • srv/src/gen/java: Contains the compiled CDS model and generated accessor interfaces for typed access.
  • nodeand node_modules: Contain a local Node.js installation and dependencies for the CDS compiler unless you specify -Dcdsdk-global when starting the build.

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 and node_modules.

 

#2) As an alternative ,you can also use the CAP CDS init command

 

Alternatively, you can use cds init to bootstrap a CAP Java application based on Spring Boot. Run the following command:

cds init <PROJECT-ROOT> –add java

You can also specify the package name through parameter –java:package. Default for the package name is: org.<PROJECT-ROOT>.

cds init <PROJECT-ROOT> –add java –java:package <java package name>

The artifactId is set to <PROJECT-ROOT> and the groupId to customer

Import the CAP JAVA Project

  1. In Eclipse , Select File > Import… > SAP Cloud Business Application.
  2. Select the xmlfile in your project and click Finish.

Compile the  CAP JAVA Project

  1. In Eclipse ,Right-click on the xml file in the project root folder and select Run as > Maven build
  2. Enter the string clean install   to the field labeled with Goals and click Run.

Note : This step compiles your CDS artifacts. Repeat this step once your CDS model changes.

You can also run mvn clean install from command prompt form your project location.

Run and Test the Application

  1. Right-click on the project root in the Package Explorer and select Run as > Spring Boot App.

or from command prompt run below command by navigating to your project root folder

 

                    mvn spring-boot:run

 

  1. Call the application in your browser at http://localhost:8080/.

This should show the automatically generated index page of served paths for oData Services /Rest API’s

 
Note : To Install the dependencies of the db CAP  module manually and suppress the npm scripts:


cd db npm install --ignore-scripts

How to obtain support /help

Be the first to leave a comment
You must be Logged on to comment or reply to a post.