
jinfo Command in Linux
The jinfo command is a powerful tool used to inspect the configuration and status of Java Virtual Machines (JVMs) running on a Linux system. It provides valuable information about various JVM parameters and settings, allowing you to diagnose issues, optimize performance, and monitor the behavior of your Java applications.
Table of Contents
Here is a comprehensive guide to the options available with the jinfo command −
- Understanding the jinfo Command
- How to Use jinfo Command?
- Syntax of jinfo Command
- Options jinfo Command
- Examples of jinfo Command in Linux
Understanding jinfo Command in Linux
The jinfo command is a powerful utility in Linux that provides configuration information for Java processes. It is particularly useful for developers and system administrators who need to obtain Java Virtual Machine (JVM) configuration details without stopping the Java process or attaching a debugger.
The jinfo command is a versatile tool that can greatly assist in the management and troubleshooting of Java applications. By providing real-time access to JVM configurations, it enables a deeper understanding and control over Java processes running in a Linux environment.
Whether you're adjusting JVM flags on the fly or gathering information for debugging, jinfo is a command that can prove to be indispensable in your toolkit:
jinfo

How to Use jinfo Command in Linux?
The jinfo command in Linux is a powerful tool for retrieving Java Virtual Machine (JVM) configuration information. It's particularly useful for developers and system administrators who need to gather JVM and Java system properties for running Java processes.
Syntax of jinfo Command
The basic syntax of the jinfo command is as follows:
jinfo [option] pid
Where pid is the process ID of the Java process you want to inspect.
Options jinfo Command
Here's a detailed look at the options available with the jinfo command:
Option | Description |
---|---|
-flag name | This option allows you to print the name and value of a specific JVM command-line flag. |
-flag name=value | This sets a specific command-line flag to the value provided. |
-flag [+|-]name | With this option, you can enable or disable a specified Boolean command-line flag. The '+' sign turns the flag on, while the '-' sign turns it off. |
-flags | This prints all command-line flags passed to the JVM. It's a quick way to see the settings that were used during the JVM's startup. |
-sysprops | Use this to print Java system properties. These are key-value pairs that provide information about the system environment. |
-h or -help | If you need assistance with the jinfo command or want to see a summary of options, this will print out a helpful message. |
Examples of jinfo Command in Linux
Take a look at the following examples to get a clear understanding of how the jinfo command works in Linux:
- Basic Usage
- Displays the value of the specified JVM flag
- List all JVM flags and their values for the JVM with PID 8026
- Displays system properties configured for the JVM
- Lists command-line arguments passed to the JVM
- Prints usage information for the jinfo command
- Print the system properties set for the JVM
- Changing JVM Configuration at Runtime
- Find the PID of a running Java process
- Remote Debugging
Basic Usage
Running jinfo without any options will print both the command-line flags and the system properties for the specified Java process.
jinfo 12345

This command will display all the JVM options and system properties for the process with ID 12345.
Displays the value of the specified JVM flag
Display the maximum heap size of the JVM with PID 6125. -flags lists all JVM flags and their current values.
jinfo -flag MaxHeapSize 6125

This command shows the maximum heap size (in bytes) set for the JVM with PID 6125.
List all JVM flags and their values for the JVM with PID 8026
The -flags option will print all the command-line flags used to start the JVM, which can be useful for debugging performance issues. This will list all the JVM startup flags for the process with ID 8026:
jinfo -flags 8026

Displays system properties configured for the JVM
This command provides a detailed overview of all JVM flags and their settings for the JVM with PID 8963. -env shows environment variables available to the JVM:
jinfo -sysprops 8963

This command lists all system properties set for the JVM with PID 8963.
Lists command-line arguments passed to the JVM
This command displays the environment variables that the JVM with PID 1234 can access.
jinfo -env 1234

This command shows the command-line arguments that were used when starting the JVM with PID 1234.
jinfo -clargs 1234

Prints usage information for the jinfo command
This command displays the available options and their descriptions for the jinfo command. The -h or -help option will display a help message, providing a quick reference for the jinfo command usage.
jinfo -help

This will show the help message for jinfo.
Print the system properties set for the JVM
The -sysprops option will print the system properties set for the JVM. This can help you understand the environment in which the Java process is running.
jinfo -sysprops 12345

This command will display the system properties for the Java process with ID 12345.
Changing JVM Configuration at Runtime
One of the advanced features of jinfo is the ability to modify certain JVM options at runtime. For example, to enable verbose garbage collection logging, you can use:
jinfo -flag +PrintGC 12345

And to disable it:
jinfo -flag -PrintGC 12345

These commands will enable or disable the PrintGC flag for the Java process with ID 12345, respectively.
Find the PID of a running Java process
Show system properties configured for the JVM with PID:
jps

Remote Debugging
jinfo can also be used to connect to a remote debug server. The syntax for this is slightly different:
jinfo [option] [server-id@]remote-hostname-or-IP
For instance, to get system properties from a remote Java process, you would use:
jinfo -sysprops [email protected]

This command retrieves the system properties from the Java process running on the remote host with the specified server ID.
Limitations and Considerations
It's important to note that jinfo is an unsupported utility and may not be available in future versions of the JDK. Additionally, it is not available on all platforms, such as Windows or Linux Itanium platforms.
Conclusion
The jinfo command is versatile and can be used in various scenarios, such as troubleshooting, monitoring, and performance tuning of Java applications. By understanding and utilizing these options, you can gain valuable insights into the JVM's configuration and behavior.