Updated on 2022-11-18 GMT+08:00

Commissioning an Application in Linux

Scenario

Run a sample program in Linux after code development is complete.

Procedure

  1. In IntelliJ IDEA, configure the Artifacts information of the project before generating the JAR package.

    1. Enter IntelliJ IDEA and choose File > Project Structure.
    2. On the Project Structure page, select Artifacts, click the plus sign (+), and choose JAR > Empty.
      Figure 1 Add Artifacts
    3. Set the name, type, and output path of the JAR package based on the site requirements.
      Figure 2 Setting basic information
    4. Choose 'kafka-examples' compile output, right-click Put into Output Root, and click Apply.
      Figure 3 Put into Output Root
    5. Click OK to complete the configuration.

  2. Generate the JAR package.

    1. Enter IntelliJ IDEA and choose Build > Build Artifacts.
      Figure 4 Build Artifacts
    2. In the displayed interface, choose kafka-example:jar > Build to generate the JAR package.
      Figure 5 Build
    3. If log similar to the following is displayed in event logs, the JAR package is successfully generated. Obtain the JAR package from the Output directory configured shown in Figure 2
      14:37 Compilation completed successfully in 25 s 991 ms

  3. Copy the generated jar package to /opt/client/lib.

    Figure 6 File Location

  4. Copy all files in the src/main/resources directory of the IntelliJ IDEA project to the src/main/resources directory at the same level as the lib folder, that is, /opt/client/src/main/resources.
  5. Ensure that the current user has read permission of all the files in the src/main/resources and lib folders in /opt/client, jdk has been installed,and java environment variables are set. Then, run the command, for example, java -cp /opt/client/lib/*:/opt/client/src/main/resources com.huawei.bigdata.kafka.example.Producer to run the example project.