This topic describes how to develop a Java program by using MaxCompute Studio and describes related directories.


Follow these steps to develop a Java program in MaxCompute Studio:
  1. Create a MaxCompute Java module.
  2. Develop a Java program based on one of the following topics:
  3. Package the Java program, upload the JAR package, and register a function.

Local module directory

MaxCompute Studio automatically creates a Maven module after you create a MaxCompute Java module. The Maven module directory includes:
  • examples: stores sample code. You can reference the sample code to develop a script for unit testing.
  • src/main/java: stores source code for Java program development.
  • warehouse: stores the schemas and data of tables that are required to run local tasks. For more information, see Local warehouse directory.

Local warehouse directory

The local warehouse directory in MaxCompute Studio stores the schemas and data of tables and resources for MaxCompute projects. These tables and resources are used to run user-defined functions (UDFs) or MapReduce tasks. The following figure shows the warehouse directory.
  • The warehouse directory contains three levels of subdirectories. Level-1 subdirectories are named by project name. Level-2 subdirectories include _resources_ and _tables_. Each level-3 subdirectory under _tables_ is named by a table name and contains the _schema_ and data files.
  • In a _schema_ file, configure the project name, table name, and names and data types of columns. Separate each pair of column name and data type with a colon (;). If a partitioned table is used, you must specify partition key columns. In the preceding figure, wc_in1 is a non-partitioned table, and wc_in2 is a partitioned table.
  • In a data file, table data is stored in the CSV format based on the following rules:
    • Special characters include commas (,), double quotation marks ("), and line breaks (\n or \r\n).
    • A comma (,) is used as a column delimiter. \n or \r\n is used as a row delimiter.
    • If a value in a column contains special characters, enclose the value in a pair of double quotation marks ("). For example, write 3,No as "3,No".
    • If a value in a column contains double quotation marks ("), use a pair of double quotation marks to escape each double quotation mark ("). For example, write a"b"c as "a""b""c".
    • \N indicates a NULL value. For a column of the STRING data type, write \N as """\N""".
    • Characters are encoded in UTF-8.