Code Monkey home page Code Monkey logo

jni-maven-example's Introduction

Build and Install

Prerequisites:

  • Required operating systems:

    • Ubuntu* Desktop-16.04-LTS 64bits
  • Use the following command to install the required tools:

    $ sudo apt-get install maven
    $ sudo tar -xvzf jdk-8u144-linux-x64.tar.gz -C /usr/lib/jvm/
  • Update environment variables
    $ export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_144
    $ export CLASSPATH=$JAVA_HOME/lib:$CLASSPATH
    $ export PATH=$JAVA_HOME/bin:$PATH
    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${Project_basedir}/native/src/main/cpp/lib
  • Add dynamic linker for run-time bindings if you have some custom libraries for native codes. Assume you install your libraries under "${Project_basedir}/native/src/main/cpp/lib", please save the settings below as "jnidemo.conf" under /etc/ld.so.conf.d/
    ${Project_basedir}/native/src/main/cpp/lib
  • Update ldconfig
    $ sudo ldconfig

Compile

  • To compile, enter the following command:
    $ mvn compile  
  • The build above would download a lot of dependent libraries. If you get the time-out warnings/errors, please save this proxy settings as "settings.xml" under ${HOME}/.m2/
    <settings>
      <proxies>
       <proxy>
          <id>httpsproxy</id>
          <active>true</active>
          <protocol>https</protocol>
          <host>${host_url}</host>
          <port>${host_port}</port>
          <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
        </proxy>
      </proxies>
    </settings>

Test

  • To Test, enter the following command:
    $ mvn test
  • If succeed, You can find the report as below in the debugging logs:
    -------------------------------------------------------
    T E S T S
    -------------------------------------------------------
    Running com.github.projects.demoproc.DemoProcTest
    Hello World!

    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.056 sec

    Results :

    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

Build package and install

  • To build package, enter the following command:
    $ mvn package
  • If succeed, You can find the file "demoproc-jni-1.0-jar-with-dependencies.jar" located under ${Project_basedir}/jni/target:

  • To install into your local repository:

    $ mvn install:install-file -Dfile=demoproc-jni-1.0-jar-with-dependencies.jar -DgroupId=com.github.projects 
          -DartifactId=demoproc-jni -Dversion=1.0 -Dpackaging=jar

Run as a background process

    $ nohup mvn exec:java &

Clean

  • If you want to clean the files generated by previous mvn compile command, enter the following command:
    $ mvn clean

jni-maven-example's People

Contributors

huangxuwei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.