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.
Fill the form and click on register button. Once done, login to
Click on “Cloud Foundry Trial”. Currently SAP Cloud Foundry is available in 4 data centers as shown below. Select “Europe(Frankfurt)”.
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.
Click on the subaccount “trial” to view your Cloud Foundry account details.
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 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
Click on environment variable and add “C:\Program Files\Cloud Foundry” to Path variable
Log on to the Cloud Foundry Instance
Open Command prompt and enter following commands.
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.
Enter cf login command to login. Specify your user id and password you used to register SAP Cloud Platform account.
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.
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
Copy the URL (in this case helloworld-java.cfapps.eu10.hana.ondemand.com) and paste it in browser. You will see the application running.
You can also check this application running in your account.
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.