Java-Based Apps on SCP: Part 1-Setup Eclipse

I am following openSAP course “Developing Java-Based Apps on SAP Cloud Platform* (Update Q1/2017)”. In this part, I’m going to setup and configure Eclipse IDE for Java EE development.
A. Install Eclipse for Java EE
- Download Eclipse IDE for Java EE Developers here.
- Extract the package to a folder of your choice and run eclipse.exe
- Select your workspace folder.
B. Setup Proxy (Optional)
- Go to Windows → Preferences and search for proxy.
- Under General → Network Connections, change Active Provider to Manual and setup your proxy accordingly.

C. Install SAP Tools
- Go to Help → Install New Software…
- Click Add… and enter the following:
Name: SAP Tools
Location: https://tools.hana.ondemand.com/neon - Click OK.
- Select all items and click Next.
- Follow on-screen instructions until the installation finish and Eclipse restarts.

D. Install Java Web Tomcat 8 SDK
- Download Java Web Tomcat 8 from this page.
- Extract the package to a folder of your choice.
- Go to Preferences → Server → Runtime Environment and click Add…
- Select SAP → Java Web Tomcat 8 and click Next.
- Click Browse… and select your JDK folder.
- Click Finish.

E. Check Java Version
- Open Command Prompt and use command
java -version
C:\Users\administrator>java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 8.1.000)
SAP Java Server VM (build 8.1.000 25.11-b08, Aug 8 2014 00:49:10 - 81_REL - optU - windows amd64 - 6 - bas2:223465 (mixed mode))
Here, the SAP JVM version 8 is installed. You can download the SAP JVM from this page.
2. Go to Preferences → Java → Installed JREs.
3. Here you find the list of JREs configured for Eclipse. Make sure Java 8 (either Oracle’s or SAP’s) is installed.

4. Open System Properties → Environment Variables and make sure JAVA_HOME is set properly.

F. Create New Dynamic Web Project
- In Eclipse, open Java EE perspective.
- Go to File → New → Dynamic Web Project.
- Input this information:
Project name: helloworld
Target runtime: Java Web Tomcat 8 - Click Finish.

G. Create New Servlet
- Right-click at the project and select New → Servlet.
- Input the following:
Java package: helloworld
Class name: HelloWorldServlet - Click Next.
- Change the URL Mappings to
/
- Click Finish.

6. In the new servlet, make the following change:
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// response.getWriter().append("Served at: ").append(request.getContextPath());
response.getWriter().println("Hello World!");
}
H. Run the App Locally
- Right-click the project, select Run As → Run on Server.
- Select Manually define a new server and Java Web Tomcat 8.
- Click Finish.

4. You should see the servlet running in the built-in browser.

5. You can re-run again as you want:

I. Run the App on SCP
- Right-click the project, select Run As → Run on Server.
- Select Manually define a new server and SAP Cloud Platform.
- Input
hanatrial.ondemand.com
in Landscape host field and click Next. - Input your Account name (e.g. p1940750502trial), User name (e.g. P1940750502), and password. Click Finish.
- Wait until the servlet is deployed and its status changes to Started.
- The application should appears automatically.

J. Install Git Client and Maven
- Download and install Git client from here.
- Download Maven from here.
- Extract the package to your folder of choice.
- Add Maven’s bin folder to the PATH environment variable.
- In Command Prompt, use command
mvn -v
to display version of Maven installed.
C:\Users\administrator>mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T02:39:06+07:00)
Maven home: E:\apache-maven-3.5.0\bin\..
Java version: 1.8.0_11, vendor: SAP AG
Java home: E:\sapjvm_8\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2012 r2", version: "6.3", arch: "amd64", family: "windows"