SAP Cloud Foundry Vs Neo we explained the difference between Neo and SAP Cloud Foundry environment in SAP Cloud Platform. We also explained how you can get free access to Neo Environment of SAP Cloud Platform.

In this article, we will explain how to:

  • Get free access to SAP Cloud Foundry trial environment
  • Download and install cf CLI tool
  • Run Java programs in SAP Cloud Foundry

 

How to get access to SAP Cloud Foundry Trial Account

Go to https://account.hanatrial.ondemand.com_ and click on register.

Get Free Access to SAP Cloud Foundry and Run Java Application

Fill the form and click on register button. Once done, login to

Get Free Access to SAP Cloud Foundry and Run Java Application

Click on “Cloud Foundry Trial”. Currently SAP Cloud Foundry is available in 4 data centers as shown below. Select “Europe(Frankfurt)”.

Get Free Access to SAP Cloud Foundry and Run Java Application

Your subaccount, org and space will be created. Click on “Go to Space” once done. Finally you should be able to view your space details in the cockpit as below.

Get Free Access to SAP Cloud Foundry and Run Java Application

Click on the subaccount “trial” to view your Cloud Foundry account details.

Get Free Access to SAP Cloud Foundry and Run Java Application

The cockpit shows the organization (named trial_trial) that contains your newly created space (named “dev”).
It also shows the API Point which is https://api.cf.eu10.hana.ondemand.com

Download and Install Cloud Foundry Command Line Interface (cf CLI)

You need to download and set up the Cloud Foundry command line interface (cf CLI) to start working with the Cloud Foundry environment.

Download CLI
Download the latest version of cf CLI from GitHub at the following URL:https://github.com/cloudfoundry/cli#downloads

  • For Microsoft Windows, download the Windows 64 bit installer.
  • For Mac OS, download the PKG file. You can use the Homebrew open source package management software to download the latest available version of the cf CLI.

Install cf CLI:

  • For Microsoft Windows, unpack the ZIP file and run the cf executable file. When prompted, choose Install.
  • For Mac OS, Open the PGK file. In the installation wizard, choose Continue, and then select the destination folder for the cf CLI installation. Choose Continue, and when prompted, choose Install.

Update Path Variable
Go to Control Panel -> Advanced System Settings

Get Free Access to SAP Cloud Foundry and Run Java Application

Click on environment variable and add “C:\Program Files\Cloud Foundry” to Path variable

Get Free Access to SAP Cloud Foundry and Run Java Application

Log on to the Cloud Foundry Instance

Open Command prompt and enter following commands.

  cf api https://api.cf.eu10.hana.ondemand.com

Note 1: Based on the region of CF, the API point might be different. Check API point in the cockpit as shown above.

Note 2: If there is proxy setup in your system, you may have to set the proxy by running below commands.

  set http_proxy=http://proxy.wdf.sap.corp:8080
set https_proxy=http://proxy.wdf.sap.corp:8080
set HTTP_PROXY=http://proxy.wdf.sap.corp:8080
set HTTPS_PROXY=http://proxy.wdf.sap.corp:8080
set no_proxy=localhost,127.0.0.1
set NO_PROXY=localhost,127.0.0.1

Enter cf login command to login. Specify your user id and password you used to register SAP Cloud Platform account.

Get Free Access to SAP Cloud Foundry and Run Java Application

Run Java Hello World Program in SAP Cloud Foundry

Download the Java Hello World program from here. Extract the zip file to a location. For example “C:\CF-Java-HelloWorld”.

Open Command Prompt and login to cloud foundry as explained in previous paragraph.

Enter the command “CD cf_folder_path.

Get Free Access to SAP Cloud Foundry and Run Java Application

Enter the command “cf push” to publish the Hello World application. Finally, the application should be started, and the app URL should be provided as below. For example, in this case, it is helloworld-java.cfapps.eu10.hana.ondemand.com

Get Free Access to SAP Cloud Foundry and Run Java Application

Copy the URL (in this case helloworld-java.cfapps.eu10.hana.ondemand.com) and paste it in browser. You will see the application running.

Get Free Access to SAP Cloud Foundry and Run Java Application

You can also check this application running in your account.

Get Free Access to SAP Cloud Foundry and Run Java Application

Cloud Foundry Examples in Node.js, Python and PHP

Refer to this article. Here we have explained in detail how to deploy and run Node.js, Python and PHP hello world program in SAP Cloud Foundry.

Common Issues and Errors

“The host is taken”. Or The host name already exists.
Apps names are global. Hence you may encounter this error. To fix that, add a suffix or prefix (or change the entire name) to the “host” attribute within the manifest.yml file.

There is insufficient memory remaining for heap.
Java buildpack 4.0 has an enhancement to the JVM memory calculation and the new memory calculator now accounts for several different memory regions.
The simplest and recommended solution to this problem is to increase the available memory to your application. Run your application with memory allocation of 1024M at least. In Manifest.yml file you can increase the memory.

Have any question? Feel free to post that in comment.

One thought on “Get Free Access to SAP Cloud Foundry”

Leave a Reply

Your email address will not be published. Required fields are marked *