Updated on 2023-08-31 GMT+08:00

Compiling and Running an Application When No Client Is Installed

Scenario

In a Linux environment where no HBase client is installed, you can upload the JAR package to the Linux and then run an application after the code development is complete.

Prerequisites

  • A JDK has been installed in the Linux environment. The version of the JDK must be consistent with that of the JDK used by the JAR package exported by IntelliJ IDEA.
  • If the Linux host is not a node in the cluster, set the mapping between the host name and the IP address in the hosts file on the node. The host name and IP address must be in one-to-one mapping.

Procedure

  1. Export a JAR package. For details, see 1 in section Compiling and Running an Application When a Client Is Installed.
  1. Prepare for the required JAR packages and configuration files.

    1. In the Linux environment, create a directory, for example, /opt/test, and create subdirectories lib and conf. Export the JAR package that the sample project depends on. For details about how to export the JAR package, see 2 in 1.4.2.1 Compiling and Running an Application When a Client Is Installed. Upload this JAR file and that exported in 1 to the lib directory on the Linux server. Upload the configuration file obtained in section Preparing the Configuration Files for Connecting to the Cluster to the conf directory on Linux..
    2. In /opt/test, create the run.sh script, modify the following content, and save the file:
      #!/bin/sh
      BASEDIR=`cd $(dirname $0);pwd`
      cd ${BASEDIR}
      for file in ${BASEDIR}/lib/*.jar
      do
      i_cp=$i_cp:$file
      echo "$file"
      done
      for file in ${BASEDIR}/conf/*
      do
      i_cp=$i_cp:$file
      done
      
      java -cp .${i_cp} com.huawei.bigdata.hbase.examples.TestMain

  2. Go to /opt/test and run the following commands to run the JAR packages:

    sh run.sh