
2011/12/24 Sergey Sudakovich (ssudakov) <ssudakov@cisco.com>:
I am writing a java based client that would be executed from windows that will use libvirt.
1. Got libvirt-java ( http://libvirt.org/sources/java/libvirt-java-0.4.7.tar.gz) and build a jar out it (ant with no params)
2. Then, according to http://libvirt.org/windows.html, built a dll using the “MSYS build script”
3. Got 2 files libvirt-0.dll and libqemu-0.dll
When I run the sample example(from Eclipse) from http://libvirt.org/java.html I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'virt': %1 is not a valid Win32 application.
The problem here might be that the Java bindings are looking for a library called 'virt' which actually means it's looking for libvirt.dll instead of libvirt-0.dll. There are two workarounds to try. You can rename libvirt-0.dll to libvirt.dll or you can change the Java bindings code in org/libvirt/jna/Libvirt.java from Libvirt INSTANCE = (Libvirt) Native.loadLibrary("virt", Libvirt.class); to Libvirt INSTANCE = (Libvirt) Native.loadLibrary("virt-0", Libvirt.class); Also make sure that the Java VM can find libvirt-0.dll at all. It needs to be in the PATH or in the working directory of you application. -- Matthias Bolte http://photron.blogspot.com