I was trying to use jmockit to unit test my project and got the following error:
java.lang.UnsatisfiedLinkError: no attach in java.library.path
java.lang.Ill
Dao Lam, Here are some other things to try:
I've found that any one of these measures will allow Eclipse to find the attach.dll.
Add the path to attach.dll to your PATH environment variable
Go to Java Build Path of your project and change the JRE System Library and make it points to the jdk instead of jre.
You have to set agent. You can set VM arguments if you are using eclipse and Args will be like this:
-javaagent:local path to your jmockit jar\jmockit.jar
eg: -javaagent:D:\jmockit.jar
It's not tools.jar
that you need, but the native library file for the "Attach API": attach.dll
(or the Linux/Mac equivalent, attach.so
or similar). A plain JRE does not contain this library. Instead, point Eclipse to a JDK installation, which should contain the jre/bin/attach.dll
file.
I found this issue with JDK 1.8.45 and 1.8.80 on 64-bit Windows. My solution was to copy attach.dll from the JDK's ./jre/bin directory to the ./bin. This eliminated the need for updating Eclipse and a Cygwin command line with a non-standard JAVA_HOME.
Maybe the Windows version may be ignoring the contents of the JRE directory?