Run Tomcat in debug mode with Intellij on MacOS

In this article we will learn how to configure to run Tomcat in debug made with IntelliJ.

1) Download the tomcat for MacOS.  You need to download tar.gz file for MacOS. I have used Tomcat 8 for debug setup.

2) Press Command + Space and type “terminal” in the search bar.

3) Go to the tomcat directory from the terminal and extract the folder contents by typing below command:

tar -xvf apache-tomcat-8.tar.gz

4) It will extract the folder contents in the same location.

5) Go to the bin folder and type below command:

./catalina.sh jpda run

jpda is the switch to run the Tomcat in debug mode. By default Tomcat run on 8000 port for debug mode.  If you need to change the port number, you need to make changes in the bin/Catalina.sh file by setting

export JPDA_ADDRESS=8180

8180 will be the port to run the Tomcat on debug mode.  It can be any value.

6) Now go to IntelliJ IDE.

7) Navigate to Run > Edit Configurations Option

Screen Shot 2016-07-11 at 10.35.34 PM

8) A New Dialog box will appear:

Screen Shot 2016-07-11 at 10.37.18 PM

9) Click on + sign on the window for adding new configuration and select Remote option from the dialog box.

Screen Shot 2016-07-11 at 10.38.22 PM

10) Provide the name of the configuration and in the port box provide the port number which has been configured.

Screen Shot 2016-07-11 at 10.40.49 PM

11) From the toolbar select the remote configuration name and click on the icon with bug picture.

Screen Shot 2016-07-11 at 10.42.38 PM

The Tomcat is configured now for debug mode.  Just put breakpoint at the code line and you will be able to run and debug the code.

 

 

 

 

2 thoughts on “Run Tomcat in debug mode with Intellij on MacOS

Leave a Reply

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