Profile Image

What is JVM startup parameter: agentlib?

What is JVM startup parameter: agentlib? Have you used this JVM arguement before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvmargument

  • agentlib

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky



The JVM parameter agentlib is used primarily to mount local library packages.




Starting from JDK 1.5




java -agentlib:<lib-name>[=options]




An example to run Java Debug Wire Protocol (JDWP) which is mainly for debugging your Java project:


java -agentlib:jdwp[=options] MainClass


You can use it with different libraries, such as HPROF (A Heap/CPU Profiling Tool) with the command:


java -agentlib:hprof[=options] ToBeProfiledClass




“agentlib” was introduced in Java 1.5 to allow you to load a library. It looks up the library depending on each running platform. Generally, the “lib-name” in the syntax is expanded to an operating system specific file name and the [options], which can be optional for some libraries, will be passed to the given agent on start-up. For example, if the option -agentlib:name is specified, the virtual machine will attempt to load the shared library name.dll from the system PATH under Windows or from the LD_LIBRARY_PATH under the Solaris operating environment.


Default Value:


The default is an empty library.




The library should exist in the PATH under Windows or LD_LIBRARY_PATH under the Solaris operating environment.


Arguments related:




Related Posts

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvmargument

  • agentlib