All Products
Search
Document Center

MaxCompute:Develop Java UDFs with IntelliJ IDEA

Last Updated:Aug 21, 2026

IntelliJ IDEA is an integrated development environment (IDE) for Java used to quickly develop Java programs. This topic shows you how to use MaxCompute Studio, a plug-in for IntelliJ IDEA, to develop a Java user-defined function (UDF) that converts uppercase letters to lowercase letters.

Prerequisites

Ensure that you have completed the following preparations in IntelliJ IDEA:

  1. Install MaxCompute Studio

  2. Create a MaxCompute project connection

  3. Create a MaxCompute Java module

Procedure

  1. Write a Java UDF.

    1. In the Project area, right-click the module's source directory (i.e., src > main > java), and select New > MaxCompute Java.

    2. In the Create new MaxCompute java class dialog box, click UDF, enter a Name, and then press Enter. For example, the Java class name is Lower.

      The Name field specifies the name of the MaxCompute Java class. If you have not created a package, you can enter packagename.classname to automatically generate a package.

    3. In the code editor, enter the following code.

      The following code is an example of the UDF.

      package <packagename>;
      import com.aliyun.odps.udf.UDF;
      public final class Lower extends UDF {
          public String evaluate(String s) {
              if (s == null) { 
                 return null; 
              }
                 return s.toLowerCase();
          }
      }
  2. Debug the UDF to ensure that it runs correctly.

    1. In the java directory, right-click your Java class and select Run.

    2. In the Run/Debug Configurations dialog box, configure the run parameters.

      • MaxCompute project: The MaxCompute project in which to run the UDF. Select local to run the UDF locally.

      • MaxCompute table: The name of the MaxCompute table to use.

      • Table columns: The columns of the MaxCompute table to use.

    3. Click OK. The result is shown in the following code.

      package wd_udf;
      import com.aliyun.odps.udf.UDF;
      public class Lower extends UDF {
      
          public String evaluate(String s) {
              if ("null".equals(s) ) {
                  return null;
              }
              return s.toLowerCase();
          }
      }
  3. Register the MaxCompute UDF.

    1. Right-click the UDF Java file and select Deploy to server....

    2. In the Package a jar, submit resource and register function dialog box, configure the following parameters.

      • MaxCompute project: The MaxCompute project that contains the UDF. Keep the default value, as the plug-in automatically selects the current project.

      • Resource file: The path of the resource file required by the UDF. You can keep the default value.

      • Resource name: The resource required by the UDF. You can keep the default value.

      • Function name: The name used to call the UDF in SQL statements. For example, Lower_test.

    3. Click OK to complete the UDF registration.

  4. Call the UDF.

    In the left-side navigation pane, click Project Explorer. Right-click your target MaxCompute project and select Open in Console. In the Console, enter an SQL statement to call the UDF and press Enter.

    package com.aliyun.odps.udf.example;
    import com.aliyun.odps.udf.UDF;
    public final class Lower extends UDF {
        public String evaluate(String s) {
            if (s == null) {
                return null;
            }
            return s.toLowerCase();
        }
    }

    Run the following command in the Console:

    select lower_test('ABC');

    The following SQL statement is an example.

    select Lower_test('ALIYUN');

    The result shows that the Lower_test Java UDF is ready to use.

    +------------+
    | _c0        |
    +------------+
    | aliyun     |
    +------------+
    1 records (at most 10000 supported) fetched by instance tunnel.