문제

J9를 사용하여 JNA를 사용하는 첫 번째 난이도는 J9 JVM에서 java.awt 패키지를 포함하지 않으며이 패키지에서 몇 개의 클래스를 가져 오는 것입니다.이것은 JNA 소스를 다운로드하고 이러한 가져 오기를 찢어냅니다 (어쨌든 사용하지 않는 경우)을 습지하고 새로운 JNA 항아리를 구축함으로써 쉽게 극복합니다.

여기에 간단한 테스트 프로그램이 있습니다.

    public class TestJni {
        public static void main(String[] args) {
            CLibrary instance = (CLibrary) Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"), CLibrary.class);     
            instance.printf("Hello, World\n", new Object[] {});
        }

        // This is the standard, stable way of mapping, which supports extensive
        // customization and mapping of Java to native types.
        public interface CLibrary extends Library {        
            void printf(String format, Object[] args);
        }
    }
.

java.awt 문제를 해결 한 후 오류가 발생합니다 :

Caused by: java.lang.UnsatisfiedLinkError: C:\DOCUME~1\TSO0112\LOCALS~1\Temp\jna72681.dll (Incompatible JNI version (not 1.1, 1.2 or 1.4))
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:973)
at java.lang.System.load(System.java:459)
at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:696)
at com.sun.jna.Native.loadNativeLibrary(Native.java:620)
at com.sun.jna.Native.<clinit>(Native.java:104)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:187)
at TestJni.main(TestJni.java:8)
.

"호환되지 않는 JNI 버전"이 무엇을 의미합니까?JNA로 멋지게 놀기 위해 J9가있는 사람이 있습니까?

업데이트 : JNA는 Java.nio.Buffer 클래스를로드하려고 시도하는 NOCLAssDeffoundError를 억제하는 것입니다.

JNA: Problems loading core IDs: java.nio.Buffer
Exception in thread "main" java.lang.NoClassDefFoundError: java.nio.Buffer
    at java.lang.ClassLoader.loadLibraryWithPath(Native Method)
    at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:965)
    at java.lang.System.load(System.java:459)
    at TestJni.main(TestJni.java:8)
.

도움이 되었습니까?

해결책

I have been working with JNA on j9 for a couple of months now. I have had a few small niggles here and there but things mostly seem working fine.

First - The latest versions of JNA(3.2.7) seem to import awt. I am using 3.2.4 and the awt imports are commented out. I think that will work out of the box for you.

Second - THe version of J9 i am working with is for WinCE and it is a JVM for java 1.4. Latest JNA though is built off of java 1.5. So you might want to check which version of java your version of j9 is built on. JNA 3.2.4 is compatible with java 1.4 I believe.

다른 팁

You can also simply provide your own stub implementations of the java.nio/java.awt stuff and simply avoid using those features (mainly direct buffer stuff and obtaining a handle to a native window).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top