nokiatech / heif

High Efficiency Image File Format
Other
1.75k stars 248 forks source link

how can I run it with JAVA #54

Open muzhen407 opened 6 years ago

muzhen407 commented 6 years ago

My build command are as following, and succeed: sudo cmake ../srcs sudo cmake --build . I see the directory "heif/srcs/api-java" has "cpp" and "java" two directories, and HEIF.java has "System.loadLibrary("heifjni");", but in directory "heif/build/lib", I can't find heifjni.so or heifjni.a. How can I build heifjni file? Looking forward to your reply.

Dawnki commented 5 years ago

My platform: win7 x64 My tools: cmake , vs2015, gradle

1.use cmake, set the source code path -> heif/srcs, and set the build path -> heif/build, configure&generate the vs2015 win64 project.

2.open the project with vs2015, find the heifjni solution & generate the heifjni.dll (heif/build/lib/Debug/heifjni.dll)

3.cd heif/build/java-desktop & gradle build, you can get the heif-java.jar (heif/build/java-desktop/build/libs/heif-java.jar)

you need the heif-java.jar & heifjni.dll to run

yanzhonghui commented 4 years ago

If use IntelliJ IDEA to develop, you can refer to mine:)

First, you need build the HEIF Source Code (Compiling under Linux Environment), than you can find the libheifjni.dylib file under build/lib.

Next, Building Java API for Windows or Linux, than you can find the heif-java.jar file under build/java-desktop/build/libs.

finally, you need copy libheifjni.dylib and heif-java.jar into your Project/libs path.

My Example: Example Project

Project Libraries

Hopefully it helped you!

JMejlikerNavent commented 4 years ago

@yanzhonghui Hi, im trying to do the same. After i make the make, i can't find the file libheifjni.dylib. Also when i try tu build at the java-desktop folder, i get this error:

  • What went wrong: A problem occurred evaluating root project 'heif-java'. Plugin with id 'java-library' not found. Can you help me with this please?
scorobogaci commented 3 years ago

HEIF Source Code

I've built in on MAC OS ,and when trying to use it i get : java.lang.UnsatisfiedLinkError: com.nokia.heif.HEIF.createInstanceNative()V

Also, the jni name is libheif_shared.dylib and not libheifjni.dylib, the name after make command under /build/lib

Also, in java api generated jar, there is hardcoded the name of of jni System.loadLibrary("heifjni");

How stupid is this, since the name generated is totally different ?

I renamed the generated libheif_shared.dylib to libheifjni.dylib, added it to java path , but getting this error now :

java.lang.UnsatisfiedLinkError: com.nokia.heif.HEIF.createInstanceNative()V

stephansann commented 3 years ago

@yanzhonghui - Thanks for sharing your success. How did you manage to get the libheifjni.dylib? I compiled the sources on my Mac and under Ubuntu with different results (see attached screenshot). Under Linux I find a "libheifjni.so", under Mac this file is a no-show.

@scorobogaci - the libheif_shared.dylib seems to be something different (it also exists in Linux (as ".so")), so renaming it to libheifjni.dylib will not help you I guess.

Screen Shot 2021-04-12 at 12 22 19
mat128 commented 2 years ago

Same here. Modifying the java sources to load "heif_shared" instead leads to the same results: java.lang.UnsatisfiedLinkError: 'void com.nokia.heif.HEIF.createInstanceNative()'