After you develop and debug a Java program, you must package the Java program into a JAR file and upload the JAR file to your MaxCompute project as a resource. Then, you can create a MaxCompute user-defined function (UDF). This topic describes how to package a Java program into a JAR file, upload the JAR file as a MaxCompute resource, and create a MaxCompute UDF.
You can also separately perform the preceding operations on MaxCompute Studio. For more information about how to package a Java program into a JAR file, see Generate a JAR package. For more information about how to create a MaxCompute UDF, see Create a function.
- In the left-side navigation pane of IntelliJ IDEA, click Project. Choose , right-click the Java program that you compiled, and then select Deploy to server….
- In the Package a jar, submit resource and register function dialog box, configure the parameters.
Parameter Description MaxCompute project The name of the MaxCompute project to which the Java program belongs. This parameter is automatically specified. You do not need to select a MaxCompute project from the drop-down list. Resource file The local directory in which the JAR file of the Java program is stored. Resource name The name of the resource as which you want to upload the JAR file to the MaxCompute project. Resource comment The comment of the resource. Extra resources Other resource files that are required for creating a MaxCompute UDF. You can select a required resource file from the resource list. If the MaxCompute UDF depends on multiple resource files, press and hold the Ctrl key, and click the required files in sequence to select them. In the Extra resources field, the resources that are added to the MaxCompute project are displayed. Main class The class of the MaxCompute UDF that you want to create. The class is defined in the Java program. Function name The name of the MaxCompute UDF that you want to create on MaxCompute Studio based on the JAR file. The UDF name is used when you call the UDF in SQL statements. Force update if already exists If you select this option, the UDF or resource that you create overwrites the existing UDF or resource that has the same name in your MaxCompute project.
- Click OK. After you complete the preceding operations, you can call the MaxCompute UDF in SQL statements.