Java to Multiple-platforms: Linux and MacOS
已回答
We are building a Java application for use on Linux and MacOS, where MacOS is the build and development platform and Linux (Ubuntu on EC2) is the ultimate target. The application is using a large Native library (.so and .dylib) that has been separately compiled on each platform. Is there a way to have a build configuration for each platform with the required Native .so/.dylib file being linked into the proper build.
Secondarily, where do I put the native libraries in the project so that the build manager will find them.
Thanks.
请先登录再写评论。
It's not IDE specific, Java loads native libraries from PATH or a location specified with java.library.path property. Another option is to handle it from your code and load the library using the full path depending on the OS.
You should be able to find a lot of examples how it can be done in the open source projects available on GitHub. http://stackoverflow.com/ is also full of answers related to loading native libraries in Java.
Serge. Thank you for the answer.
In our case, the Native library is quite large (95MB for each platform) and I would prefer not to install both in the .jar file. Is there a way to convince IntelliJ to only load one in a given artifact and not the other, and then vice-versa for the other file?
Thanks.
Sure, you can control which files are included in which artifact, see https://www.jetbrains.com/help/idea/artifacts.html.
Thank you. That's what I was looking for.