Search code examples
springgradlejava-native-interfacespring-bootjvm-arguments

Spring Boot Gradle add Native library failed (java.lang.UnsatisfiedLinkError)


I am trying to add a native library( .dll file) to a basic spring gradle project. I have tried many different settings and all of them didn't work in a basic java project , I have successfully ran that dll file by adding VM argument: java.library.path gradle here's the script:

buildscript {
  ext {
    springBootVersion = '1.2.5.RELEASE'
  }
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
  }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot' 

jar {
    baseName = 'messaging'
    version = '0.0.1-SNAPSHOT'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile("org.springframework.boot:spring-boot-starter-aop")
    compile("org.springframework.boot:spring-boot-starter-amqp")
    compile("org.springframework:spring-messaging")
    compile('javax.inject:javax.inject:1')
    compile('com.google.guava:guava:11.0.2')
    compile('org.codehaus.jackson:jackson-core-asl:1.1.0')
    compile('org.codehaus.jackson:jackson-mapper-asl:1.9.13')
    testCompile("org.springframework.boot:spring-boot-starter-test") 
   }

   task wrapper(type: Wrapper) {
      gradleVersion = '2.3'
   }

I have tried:

add VM arguments on eclipse add jvm properties add gradle system property ( can not succeeded to add that parameter)


Solution

  • I couldn't understand why but when I follow the steps below, it worked: 1. I changed the java package name 2. rebuild the project with gradle 3. run the project