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.

Note: This step is only applicable if you wish to debug your tunneled functions and if you have used the following CLI command:
copy
$
catalyst functions:shell –tunnel tunnel-port-number –debug port-number

If you wish only to tunnel your functions and you have used the following CLI command then no IDE configurations is required.

copy
$
catalyst functions:shell –tunnel tunnel-port-number

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

  1. Ensure you have all the functions you need to debug in the local machine, and open the concerned project in VS Code. catalyst_tunneling_debug_vscode_java_openprojec

  2. 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. catalyst_tunneling_vscode_debug_create_json_high

This is how the launch.json file appears before you begin configurations. catalyst_tunneling_vscode_debug_create_json_high

  1. Copy the JSON snippet below and paste it as value in the “configurations” JSON key.
    
launch.json
copy

“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 }],

  1. Save this file and apply the breakpoints in your required lines of code and proceed to the next step. catalyst_tunneling_debug_vscode_java_brkpts_set

Configure IntelliJ IDEA IDE’s Debugger

  1. Import your project directory in IntelliJ IDE, and configure the run time JDK to match your Java version. catalyst_tunneling_intellij_debugger_java_start
Note: You can find out how to configure your JDK in IntelliJ IDEA by visiting their official help documentation.
  1. Click Run>Edit Configurations. catalyst_tunneling_intellij_debugger_java_run_selection

  2. Click the + icon, select Remote JVM Debug option from the pop-up, and click OK. catalyst_tunneling_intellij_debugger_java_remote_javm_debugger

  3. 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. catalyst_tunneling_intellij_debugger_java_configurations
  4. Set the required debugging points in your code, and proceed to the next step. catalyst_tunneling_intellij_debugger_java_finally_debug

Configure Eclipse IDE’s Debugger

  1. Import your project directory in Eclipse IDE. catalyst_tunneling_debugging_java_eclipse_import_proj

  2. Ensure your Java stack and JDK are in the same version by right-clicking your project list and selecting Build Path > Configure Build Path. catalyst_tunneling_java_debug_eclipse_configure_build_path

  3. Select Project Natures. Search for “Java”, select “java” from the list and click OK. catalyst_tunneling_debugging_java_eclipse_project_nature

  4. Ensure Java Compiler is selected, and click Apply and Close to add the Java compiler for your project. catalyst_tunneling_debugging_java_eclipse_select_java_compiler

  5. Next, right-click your project directory and click Debug As > Debug Configuration. catalyst_tunneling_debugging_java_eclipse_debug_configurations

  6. Search for Remote Java Applications, right-click on the search result and select New Configurations. catalyst_tunneling_debugging_java_eclipse_select_java_new_configuratons
    You will be directed to a Debug Configurations pop-up.

  7. 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 catalyst_tunneling_debugging_java_eclipse_connect_tab
  • Source tab:

    • Click the Add button and select the function directory catalyst_tunneling_debugging_java_eclipse_source_tab

Once you have applied the required configurations, click Debug.

  1. Open your function file and set your required debug points in your code, and proceed to the next step. catalyst_tunneling_debugging_java_eclipse_final_debug

Last Updated 2024-07-23 17:40:25 +0530 +0530

ON THIS PAGE