• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

problem with library path on Windows 10

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on a sample Java Native Interface program, and was able to compile the Java portion with the latest 64-bit JDK. As you may know, this type of project also has a C source code. I have MinGw on my laptop, which run Windows 10. When I try to run the program, however I see the following error message:

C:\Users\sansari\Documents\source\java>ls
HelloJNI.c HelloJNI.class HelloJNI.exe HelloJNI.h HelloJNI.java hello.dll

C:\Users\sansari\Documents\source\java>rm hello.dll

C:\Users\sansari\Documents\source\java>gcc -Wl,--add-stdcall-alias -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" -shared -o HelloJNI.dll HelloJNI.c

C:\Users\sansari\Documents\source\java>java HelloJNI
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\sansari\Documents\source\java\HelloJNI.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at HelloJNI.<clinit>(HelloJNI.java:3)

C:\Users\sansari\Documents\source\java>java -Djava.library.path=. HelloJNI
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\sansari\Documents\source\java\HelloJNI.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at HelloJNI.<clinit>(HelloJNI.java:3)

C:\Users\sansari\Documents\source\java>ls
HelloJNI.c HelloJNI.class HelloJNI.dll HelloJNI.exe HelloJNI.h HelloJNI.java

C:\Users\sansari\Documents\source\java>ls
HelloJNI.c HelloJNI.class HelloJNI.dll HelloJNI.exe HelloJNI.h HelloJNI.java

Here is what is in my HelloJNI.java



Here are the rest of the files:

C:\Users\sansari\Documents\source\java>ls
HelloJNI.c HelloJNI.class HelloJNI.dll HelloJNI.exe HelloJNI.h HelloJNI.java

I started out with the HelloJNI.java and compiled it with javac command. I then used javah to get HelloJNI.h. Here is what is in HelloJNI.c:

 
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I can never seem to get anything to work in JNI myself, so I think it is beyond the “beginning” stage. I shall move you to another forum.
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, mingw is 32-bit only. You will need to use mingw-w64 instead.
 
Sean Ansari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. My error has changed now. Somehow I got over the earlier issue. Can you help me with this one?

 
Sean Ansari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java Native Interface Tutorial

Here is the URL I am using to learn it.
 
Sean Ansari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this also; no go ...

reply
    Bookmark Topic Watch Topic
  • New Topic