0% found this document useful (0 votes)
171 views

How To Get Java System Properties and JVM Flags of A Running Java Process - Using Jinfo

Instruction for using jinfo tool to get the java system properties and JVM flags of a running java process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views

How To Get Java System Properties and JVM Flags of A Running Java Process - Using Jinfo

Instruction for using jinfo tool to get the java system properties and JVM flags of a running java process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

S A TU R DA Y , JU LY 2 0, 2 01 3

How to get Java system properties and JVM flags of a running Java process - Using jinfo
I wanted to check the current sy stem properties and JV M flags of a Weblogic managed serv er, so I first used "wlst " (Weblogic scripting tool) to access that managed serv er. It was a little time consuming task and y ou need to hav e a knowledge about the inside of Weblogic serv er. But later I found out about this jinfo tool. jinfo is a v ery useful tool for retriev ing Jav a sy stem properties and JV M flags (JV M command line flags) (and changing v alues of JV M flags) of a running local Jav a process or a remote serv er process. It was lot easier than accessing these properties using "wlst " or "jconsole ". According to the "jinfo " documentation, This tool can also be used to get sy stem properties and JV M flags of a remote serv er process. But I am going to focus only about how to get those details of a local Jav a process in a Linux env ironment. Y ou can get the process ID of the specific process by doing a command like below in Linux . (Please replace "managed1 " with a word (main class name, for ex ample) in the command used for starting the Jav a process.)

p se f|g r e p" m a n a g e d 1 "

In the output of abov e command, y ou can get the PID of the relev ant Jav a process. Then ex ecute the following command. Please replace <PID> with the actual PID of the process.(I am assuming that path to JDK bin folder is in PATH env ironment v ariable).

j i n f o< P I D >

It will attach to the process related to that PID and will show the Jav a sy stem properties and JV M flags like below.

A t t a c h i n gt op r o c e s sI D2 5 9 6 5 ,p l e a s ew a i t . . . D e b u g g e ra t t a c h e ds u c c e s s f u l l y . S e r v e rc o m p i l e rd e t e c t e d . J V Mv e r s i o ni s1 1 . 0 b 1 7 J a v aS y s t e mP r o p e r t i e s :

j a v a . v e n d o r=S u nM i c r o s y s t e m sI n c . o r g . x m l . s a x . p a r s e r=w e b l o g i c . x m l . j a x p . R e g i s t r y P a r s e r s u n . j a v a . l a u n c h e r=S U N _ S T A N D A R D c o m . s u n . x m l . w s . a p i . s t r e a m i n g . X M L S t r e a m R e a d e r F a c t o r y . w o o d s t o

x=t r u e s u n . m a n a g e m e n t . c o m p i l e r=H o t S p o tT i e r e dC o m p i l e r s o s . n a m e=L i n u x s u n . b o o t . c l a s s . p a t h=/ o p t / j d k 1 . 6 . 0 _ 1 1 / j r e / l i b / r e s o u r c e s . j a r : / o p t / j d k 1 . 6 . 0 _ 1 1 / j r e / l i b / r t . j a r . . . w e b l o g i c . t h r e a d p o o l . M i n P o o l S i z e=5 0 j a v a . v m . s p e c i f i c a t i o n . v e n d o r=S u nM i c r o s y s t e m sI n c . . . . . . V MF l a g s :

D w e b l o g i c . N a m e = m a n a g e d 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Other features of this tool : (I didn't hav e a chance to ex periment with these y et): 1 . Get only JV M flags of the relev ant Jav a process. jinfo -flags <PID> 2. Get only Jav a sy stem properties jinfo -sy sprops <PID> 3. Get a v alue of a specific JV M flag of the relev ant Jav a process. jinfo -flag <JV M_FLAG_NAME> <PID> 4. Change the v alue of a specific JV M flag of the relev ant Jav a process. a) Enabling a boolean JV M flag, jinfo -flag +<JV M_FLAG_NAME> <PID> b) Disabling a boolean JV M flag, jinfo -flag -<JV M_FLAG_NAME> <PID> c) Setting a v alue of a JV M flag jinfo -flag <JV M_FLAG_NAME>= <NEW_V ALUE> <PID>

If you get VMVersionMism atchException, Sometimes y ou may get following V MV ersionMismatchEx ception.

A t t a c h i n gt op r o c e s sI D6 4 6 1 ,p l e a s ew a i t . . . E x c e p t i o ni nt h r e a d" m a i n "j a v a . l a n g . r e f l e c t . I n v o c a t i o n T a r g e t E x c e p t i o n a ts u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v eM e t h o d ) a ts u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( N a t i v e M e t h o d A c c e s s o r I m p l . j a v a : 3 9 ) a ts u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l .

i n v o k e ( D e l e g a t i n g M e t h o d A c c e s s o r I m p l . j a v a : 2 5 ) a tj a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( M e t h o d . j a v a : 5 9 7 ) a ts u n . t o o l s . j i n f o . J I n f o . r u n T o o l ( J I n f o . j a v a : 7 9 ) a ts u n . t o o l s . j i n f o . J I n f o . m a i n ( J I n f o . j a v a : 5 3 ) C a u s e db y :s u n . j v m . h o t s p o t . r u n t i m e . V M V e r s i o n M i s m a t c h E x c e p t i o n :S u p p o r t e dv e r s i o n sa r e 1 7 . 1 b 0 3 .T a r g e tV Mi s2 0 . 5 b 0 3 a ts u n . j v m . h o t s p o t . r u n t i m e . V M . c h e c k V M V e r s i o n ( V M . j a v a : 2 2 3 ) a ts u n . j v m . h o t s p o t . r u n t i m e . V M . < i n i t > ( V M . j a v a : 2 8 6 ) a ts u n . j v m . h o t s p o t . r u n t i m e . V M . i n i t i a l i z e ( V M . j a v a : 3 5 0 ) a ts u n . j v m . h o t s p o t . b u g s p o t . B u g S p o t A g e n t . s e t u p V M ( B u g S p o t A g e n t . j a v a : 5 9 4 ) a ts u n . j v m . h o t s p o t . b u g s p o t . B u g S p o t A g e n t . g o ( B u g S p o t A g e n t . j a v a : 4 9 4 ) a ts u n . j v m . h o t s p o t . b u g s p o t . B u g S p o t A g e n t . a t t a c h ( B u g S p o t A g e n t . j a v a : 3 3 2 ) a ts u n . j v m . h o t s p o t . t o o l s . T o o l . s t a r t ( T o o l . j a v a : 1 6 3 ) a ts u n . j v m . h o t s p o t . t o o l s . J I n f o . m a i n ( J I n f o . j a v a : 1 2 8 ) . . .6m o r e

The reason for this is, y ou are using a "jinfo " tool related to a different jav a v ersion than the JV M used to start this targeted process. If y ou get abov e ex ception, please find the JDK home of the JV M used for the targeted process, and use the "jinfo " tool in the bin folder of that JDK home. According to the jinfo tool documentation, it seems this is not a standard tool of the JDK. In the documentation, there is a note say ing "NOT E - T his utility is unsupported and m ay or m ay not be av ailable in future v ersions of the JDK. In Windows Sy stem s where d b g e n t . d l lis not present, 'Debugging T ools for Windows' needs to be installed to hav e these tools working. Also the P A T Henv ironm ent v ariable should contain the location of j v m . d l lused by the target process or the location from which the Crash Dum p file was produced. For ex am ple, s e tP A T H = \ j r e \ b i n \ c l i e n t ; % P A T H %
"

You might also like