Is it possible for the pure Java project, created at Intellij IDEA, to use .so files (like Android project does)?
Surfing over internet I can not find any information about it. Sounds very strange.
UPDATE:
What I have in Android is a simple script:
def ndkBuild;
def ndkBuildingDir = mainSrcDir;
def hasNdk = false;
if (System.env.ANDROID_NDK_HOME != null) {
hasNdk = true;
ndkBuild = new File(System.env.ANDROID_NDK_HOME, ndkBuildFilename())
}
commandLine ndkBuild, "--directory", ndkBuildingDir, "APP_BUILD_SCRIPT=${ndkBuildingDir}/native/Android.mk", "NDK_APPLICATION_MK=${ndkBuildingDir}/native/Application.mk"
And I can not found any documentation of doing such things at Java project.
In short, yes.
However it will stop being a pure Java project and will introduce a dependency on a system the native binary is compiled on/written for.
To do this, write JNi code, like you would do on android (as you seem to be familiar with that), compile into a dynamic library with certain compiler flags and then use System.loadLibrary("foo");
in your Java code, just like you would on an android project.
There's really a lot more to this though, and there's quite a few tutorials online that describe how to do this. I would suggest to try to solve the problem in Java before opting for JNI though as there's a lot of places to stumble and cause serious bugs in JNI.
I've never written any JNI code in IDEA though, I'm sure it's possible but it's not really a C or C++ IDE, so you might want to use something else for that part.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.