Guide to creating a zip package for offline tasks (Java)
Note: Java offline task applications support Java 7 and Java 8.
Specifications for a Java offline task application zip package are as follows:
Do not include start.sh or start_flow.sh in the root directory of the zip package.
The zip package must have the following structure.
xxx.zip ## The uploaded zip package must contain only the algorithm code. Do not include the start.sh and start_flow.sh files. - elastic-test-1.0-SNAPSHOT.jar - Other required algorithm filesThe elastic-test-1.0-SNAPSHOT.jar file is packaged using Maven. You must replace this with your own JAR package. To generate the JAR file, create a pom.xml file and refer to the following example for the main class.
Note: If you configure input and output parameters in Data Development, you can retrieve them using the ZERG_APP_PARAM environment variable.
public class JobTest { public JobTest() { } public static void main(String[] args) { System.out.println("job running here"); if (args != null && args.length > 0) { String[] var1 = args; int var2 = args.length; for(int i = 0; i < var2; ++i) { String s = var1[i]; System.out.println("Param: " + s); } } else { System.out.println("No param"); } System.out.println("hello world!"); System.out.println("job running success!"); } }In the folder that contains the elastic-test-1.0-SNAPSHOT.jar file and other required algorithm files, run a packaging command similar to the following example to create the java_job_test.zip file.
zip -r java_job_test.zip ./*Upload the created zip package.
Write the offline task application script.
When you add the offline task application, use the following example to write the application script.
#!/bin/bash cd `dirname $0` echo "--------start------->>" java -jar elastic-test-1.0-SNAPSHOT.jar "$1" echo "--------end------->>"After you write the script, save it.