Configure IDE to Debug Java Functions
For the purposes of this help documentation we are going to illustrate how to configure debugging preferences of Java non-HTTPS and Integration functions in Visual Studio Code, IntelliJ IDEA, and Eclipse IDEs.
If you wish only to tunnel your functions and you have used the following CLI command then no IDE configurations is required.
This command will only tunnel your functions and publish the logs of the functions in the Catalyst CLI.
Configure Visual Studio Code IDE’s Debugger
-
Ensure you have all the functions you need to debug in the local machine, and open the concerned project in VS Code.
-
Click the Run/Debug button present in the menu-bar and create a launch.json file, by clicking the “create a launch.json file” option.
This is how the launch.json file appears before you begin configurations.
- Copy the JSON snippet below and paste it as value in the “configurations” JSON key.
launch.jsoncopy
“configurations”: [{ “type”: “java”, “name”: “java_cron”, // name can be any name but having the same function name will be helpful while debugging “request”: “attach”, “hostName”: “localhost”, “port”: 9001,// The debug port number which you specified in the catalyst functions:shell –tunnel 8001 –debug 9001. The port number can be any number which is not being used by any other processes “projectName”: “java_cron”// The function name }],
- Save this file and apply the breakpoints in your required lines of code and proceed to the next step.
![]()
Configure IntelliJ IDEA IDE’s Debugger
- Import your project directory in IntelliJ IDE, and configure the run time JDK to match your Java version.
Note: You can find out how to configure your JDK in IntelliJ IDEA by visiting their official help documentation.
Click Run>Edit Configurations.
![]()
Click the + icon, select Remote JVM Debug option from the pop-up, and click OK.
![]()
Ensure you set the following values in the pop-up:
- Name: Set it as your project name or any other name of your preference.
- In the Configurations tab:
- Debugger mode: Attach to remote JVM
- Host: localhost
- Port: Set the same port value you set for debugging in the Catalyst CLI.
- Use module classpath: Select the path of your project directory.
- Click OK.
![]()
Set the required debugging points in your code, and proceed to the next step.
![]()
Configure Eclipse IDE’s Debugger
Import your project directory in Eclipse IDE.
![]()
Ensure your Java stack and JDK are in the same version by right-clicking your project list and selecting Build Path > Configure Build Path.
![]()
Select Project Natures. Search for “Java”, select “java” from the list and click OK.
![]()
Ensure Java Compiler is selected, and click Apply and Close to add the Java compiler for your project.
![]()
Next, right-click your project directory and click Debug As > Debug Configuration.
![]()
Search for Remote Java Applications, right-click on the search result and select New Configurations.
![]()
You will be directed to a Debug Configurations pop-up.Ensure you have configured the debugger with the following values:
Connect tab:
- Select your project directory
- Set Connection Type as “Standard (Socket Attach)”
- Set Connection Properties as:
- Host: localhost
- Port: Enter the port number you set for debugging in the Catalyst CLI
![]()
Source tab:
- Click the Add button and select the function directory
![]()
Once you have applied the required configurations, click Debug.
- Open your function file and set your required debug points in your code, and proceed to the next step.
![]()
Last Updated 2024-07-23 17:40:25 +0530 +0530
Yes
No
Send your feedback to us