Tools and Technologies used in this article :

  1. JMockit

  2. JUnit 3

  3. IBM JDK 6

  4. IBM Rational Application Developer

  5. Windows 7 OS



java.lang.RuntimeException: Unable to enqueue operation: the target VM does not support attach mechanism
      at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(
      at mockit.internal.startup.JDK6AgentLoader.loadAgent(
      at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(
      at mockit.internal.startup.Startup.initializeIfNeeded(
      at mockit.internal.startup.Startup.initializeIfPossible(
      at junit.framework.TestResult.<clinit>(
      at java.lang.J9VMInternals.initializeImpl(Native Method)
      at java.lang.J9VMInternals.initialize(
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Caused by: Unable to enqueue operation: the target VM does not support attach mechanism
      at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(
Note : You may get the error in-spite of enabling Attach API

The Attach API allows your application to connect to a virtual machine. Your application can then load an agent application into the virtual machine. The agent can be used to perform tasks such as monitoring the virtual machine status


Follow the steps below

  1. Download jmockit-1.6 and extract to a folder (say c:\jmockit).

  2. Select Run --> Run Configurations... --> JUnit --> Arguments and add VM arguments "-javaagent:<jmockit-path>jmockit.jar".

    Run Configurations - VM Arguments
  3. Execute JUnit test case.