Java Jar Package Deployment

Jar Project Identification Strategy

By default, the platform will recognize it as a Java Jar project based on whether there is a Jar package in the source root directory.

Platform Compilation and Operation Mechanism

  1. The pre-compilation process will detect whether the startup command configuration file Procfile is defined, and if not defined, it will generate the default Jar package startup configuration file;
  2. After the pre-compilation processing is completed, the Java-jar buildpack will be selected according to the language type to compile the project. The defined JDK version will be installed during the compilation process;
  3. After the compilation is completed, it will be checked whether the Procfile parameter is set on the platform, and if it is configured, the startup command configuration file Procfile will be overwritten.

Jar Project Source Code Specification

In this step, you need to provide a usable Java Jar source code program for deployment on the Kato platform. This application must at least meet the following conditions:

  1. Jar package that can run normally locally
  2. The source code program must be hosted on related git or svn services such as gitlab
  3. The Jar package file must exist in the root path of the source code program

Procfile Specification

If the project does not define a Procfile file, the platform will generate a default Procfile to run the Jar package by default.

web: java -Dserver.port=$PORT $JAVA_OPTS -jar ./*.jar

The above is the default Procfile, if you need to expand more startup parameters, you can customize the Procfile.

  1. There is a space between web: and java
  2. The end of the file cannot contain special characters
  3. JAVA_OPTS: The platform will automatically set the value of Xmx and Xms according to the memory size of the application
  4. PORT: The listening port is determined according to the port set by the user on the platform, the default listening port is 5000

Compile and Run Environment Settings

When choosing the JDK version or other component versions, you need to pay attention to the JDK or other component versions not to be too high or too low than the version used in the project to avoid source code compilation failure

OpenJDK Support

Currently Kato supports the following versions of OpenJDK:

  • Java 1.6 - 1.6.0_27
  • Java 1.7 - 1.7.0_95
  • Java 1.8 - 1.8.0_74
  • Java 1.9 - 1.9-latest
  • Java 10 - 10.0.2
  • Java 11 - 11.0.1

The default version of the platform uses 1.8. If you need to use another version of OpenJDK, you can specify the required version of the JDK by adding the system.properties file in the source root directory to set the value of java.runtime.version.

# system.properties The current version values ‚Äč‚Äčthat Kato can recognize are 11, 10, 1.9, 1.8, 1.7, 1.6
java.runtime.version=1.8

OracleJDK Support

The platform currently supports OracleJDK, but this feature needs to be enabled in the platform to take effect.

OracleJDK download is not built-in by default, you need to configure the relevant OracleJDK download address after enabling OracleJDK in the settings.

OracleJDK download address format requirements: http://<web service URL>/jdk-8u201-linux-x64.tar.gz

The configuration priority of the platform settings is higher than the configuration defined in the program code, such as the choice of Java JDK version. In the program code, the JDK version is specified as 1.9 through system.properties, and the JDK version is selected as 11 on the platform. Then by default, the platform-specified version JDK11 will be used first when compiling source code

Sample Demo Program

Example https://github.com/gridworkz/java-jar-demo