JPro-one / HelloJPro

HelloWorld for JPro using Gradle with Groovy
https://www.jpro.one
64 stars 22 forks source link

How to set systemProperty ? #21

Closed harideva16 closed 3 years ago

harideva16 commented 3 years ago

How can I set systemProperty java.library.path ?

I followed this https://stackoverflow.com/questions/23367507/how-to-pass-system-property-to-gradle-task

I added the following code in gradle.build file to set systemProperty.

task local {
    run {  systemProperty "java.library.path", file("${project(":hello").buildDir}/lib/main/debug").absolutePath }
}

bootRun.mustRunAfter local

But , it not worked.

How can I set systemProperty java.library.path in gradle.build file ?

harideva16 commented 3 years ago

I want to build JPRO on github actions.

so , I need to add systemProperty in gradle.build file.

Help me !!!

harideva16 commented 3 years ago

usually I set jni library path like this.

But, I didn't know about how to set system Property in gradle for all the three following os?

How can I set systemProperty java.library.path ?

I followed this answer

I added the following code in gradle.build file to set systemProperty.

task local {
    run {  systemProperty "java.library.path", file("${project(":hello").buildDir}/lib/main/debug").absolutePath }
}

bootRun.mustRunAfter local

But , it not worked.

I followed this project to implement JNI . I searched in internet about how to set system properties for java.library.path in gradle . But , no answer found.

I also asked a question in stackoverflow But , no response.

so, please help me !!!

If I run it comes an error like this java.lang.UnsatisfiedLinkError: no hello in java.library.path.

Can you give any documents or reference about it ?

How can I set systemProperty java.library.path in gradle.build file ?

Give a answer!!!!

FlorianKirmaier commented 3 years ago

You can ad JVM arguments the following ways:

For a "Normal JavaFX application" starting with ./gradlew run

applicationDefaultJvmArgs = ['-Djava.library.path=something']

For JPro, starting with ./gradlew jproRun

jpro.JVMArgs << '-Djava.library.path=something'
ghost commented 3 years ago

@FlorianKirmaier I think it's not a right answer.

Please check this : https://stackoverflow.com/a/59495773/10870644

FlorianKirmaier commented 3 years ago

I've only answered on how to add System properties. I didn't answer anything c++/"native compilation" related - which I don't know anything about. This is also not the right place to question anything related to gradle/c++ interactions.

I hope the stackoverflow answer solves your problem.