This blog post is part 3 of a series of blogs on how to develop a Java application in SAP Web IDE Full-Stack.
It describes how to Run and Debug the application, as well as our new Hot Deployment feature.
After successfully building and testing our newly created web Java module, we can finally run it.
- Right-click the web folder and select Run→Run As→Java Application.
The Run console opens displaying our Java application URL.
- Click on the URL. A new tab opens displaying a link for our Hello World Servlet
- Click on the link. Our “Hello World” output is displayed.
Let’s modify the Java code to show the Hot Deployment capability.
- Open the java class.
- Modify line 36 to be: write(“New Hello World !!”);
- Click the Run console’s green play button to rerun the application.
- The time for running the application is now faster than before
- Refresh the application page in your browser.
- Click the “Hello World Servlet” link.Voilà! our new code modification is now available
You can run your Java module in debug mode using the Run Configurations dialog.
Then, use the debug tools for debugging your application.
Let me show you how…
- Open the HelloServlet.java file under web/src/main/java/…
- Set a breakpoint on line 29 inside the doGet(..)
To achieve this, click the line number in the editor’s gutter.
- Right-click the web folder and select Run->Run Configurations. The Run Configurations dialog opens.
- Click + to add a new configuration and select the only option – Java Application.
- Once the new configuration is created, select the Run in debug mode checkbox.
- Click Save and Run to debug your web Java module.
Once the application is running, a new Debugger pane opens on the right-side paneThe Active Session name is based on the names of our project and Java module: “/mtaproj/web”.
The running Java application threads are displayed under the Call Stack(s) section.
Notice the breakpoint we just added for line 28 under the Breakpoints section.
Now let’s hit a breakpoint.
- Click the application URL from the Run console to open the application in a new tab.
A new tab opens with a link called “Hello World Servlet”.
- Click on it. The debugger is suspended.A new notification message stating Debugger: ‘/mtaproj/web’ suspended is displayed.
The Call Stack section stops on our doGet method.
The Variables section contains 4 local variables defined inside the doGet method.
Line #29 in the editor is highlighted.
- Use Step Over (F10), Step In (F11), Step Out (Shift + F11), and Resume (F8) to debug the Java code.
- You can also scan the tree to inspect the variable values.
With this blog post series, you have learnt how to create an MTA project with a Simple Web Application Java module. We integrated the very basic capabilities of Java development to help the full-stack developer throughout the software development lifecycle from Java code development to debugging and running the application.