Saturday, February 2, 2013

Java Binary Utilities

In this post, we will see how to use the list of binary executable available inside  java bin directory.Each and every binary executable have it’s own purpose.To know more about various binary utilities keep on reading ..!! 

12.08.30-Java

1.Java Virtual Machine Process Status Tool:

The jps tool lists the instrumented HotSpot Java Virtual Machines (JVMs) on the target system. The tool is limited to reporting information on JVMs for which it has the access permissions.

Example 1:

$ ./jps

24294 Jps

7209 TMMain

26764 Server

25980 Server

25833 Server

26911 Server

28316 Server

This Utility will display the list of JVM running under the local machine.So in this above example,there are 5 servers,1 Jps,1 OEM process are running.

This utility is similar to the command ps -ef|grep java.We can make use of this command.

2.Memory Map:

Jmap prints shared object memory maps or heap memory details of a given process or core file or a remote debug server. If the given process is running on a 64-bit VM, you may need to specify the -J-d64.

Example 1: jmap <no option> <pid>

When no option is used jmap prints shared object mappings. For each shared object loaded in the target VM, start address, the size of the mapping, and the full path of the shared object file are printed. This is similar to the Solaris pmap utility.

$ ./jmap 26764

Attaching to process ID 26764, please wait...

Debugger attached successfully.

Server compiler detected.

JVM version is 20.1-b02

0x0000000040000000 49K /Optional/Oracle/Middleware/jdk1.6.0_26/bin/java

0x0000003aefa00000 140K /lib64/ld-2.5.so

0x0000003aefe00000 1681K /lib64/libc-2.5.so

0x0000003af0200000 22K /lib64/libdl-2.5.so

0x0000003af0600000 142K /lib64/libpthread-2.5.so

0x0000003af0a00000 600K /lib64/libm-2.5.so

0x0000003af1200000 52K /lib64/librt-2.5.so

0x0000003af2e00000 111K /lib64/libnsl-2.5.so

0x0000003af6200000 90K /lib64/libresolv-2.5.so

0x00002aaaaaabc000 65K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/libverify.so

0x00002aaaaabcb000 229K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/libjava.so

0x00002aaaaad0c000 52K /lib64/libnss_files-2.5.so ---> These are the list of Shared objects loaded in JVM.

0x00002aaaaaf17000 90K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/libzip.so

0x00002aaab761e000 38K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/libmanagement.so

0x00002aaabc000000 110K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/libnet.so

0x00002aaabc127000 23K /lib64/libnss_dns-2.5.so

0x00002aaabc5b5000 43K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/libnio.so

0x00002aaabc6bd000 13K /Optional/Oracle/Middleware/wlserver_10.3/server/native/linux/x86_64/libmuxer.so

0x00002aaabc7c4000 21K /Optional/Oracle/Middleware/wlserver_10.3/server/native/linux/x86_64/libwlfileio3.so

0x00002aaabd4b7000 15K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/libattach.so

0x00002aaabd5ba000 49K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/libinstrument.so

0x00002b98bc900000 47K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/jli/libjli.so

0x00002b98bca0c000 13027K /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/server/libjvm.so

Example 2: jmap <option> <pid>

When option heap is specified , then this command will print the heap summary of the JVM.

JVM Heap Memory Structure:

image

$ ./jmap -heap 26764

Attaching to process ID 26764, please wait...

Debugger attached successfully.

Server compiler detected.

JVM version is 20.1-b02

using parallel threads in the new generation.

using thread-local object allocation.

Concurrent Mark-Sweep GC

Heap Configuration:

MinHeapFreeRatio = 40

MaxHeapFreeRatio = 70

MaxHeapSize = 2147483648 (2048.0MB)

NewSize = 21757952 (20.75MB)

MaxNewSize = 87228416 (83.1875MB)

OldSize = 65404928 (62.375MB)

NewRatio = 7

SurvivorRatio = 8

PermSize = 67108864 (64.0MB)

MaxPermSize = 335544320 (320.0MB)

Heap Usage:

New Generation (Eden + 1 Survivor Space):

capacity = 78512128 (74.875MB)

used = 42155592 (40.20270538330078MB)

free = 36356536 (34.67229461669922MB)

53.693095670518574% used

Eden Space:

capacity = 69795840 (66.5625MB)

used = 42155592 (40.20270538330078MB)

free = 27640248 (26.35979461669922MB)

60.398430622799296% used

From Space:

capacity = 8716288 (8.3125MB)

used = 0 (0.0MB)

free = 8716288 (8.3125MB)

0.0% used

To Space:

capacity = 8716288 (8.3125MB)

used = 0 (0.0MB)

free = 8716288 (8.3125MB)

0.0% used

concurrent mark-sweep generation:

capacity = 2060255232 (1964.8125MB)

used = 183531328 (175.02911376953125MB)

free = 1876723904 (1789.7833862304688MB)

8.908184051635017% used

Perm Generation:

capacity = 335544320 (320.0MB)

used = 234528512 (223.663818359375MB)

free = 101015808 (96.336181640625MB)

69.89494323730469% used

Example 3:

When option finalizerinfo is specified ,it will print information on objects awaiting finalization

$ ./jmap -finalizerinfo 5483

Attaching to process ID 5483, please wait...

Debugger attached successfully.

Server compiler detected.

JVM version is 20.1-b02

Number of objects pending for finalization: 0

Example 4:

Prints a histogram of the heap. For each Java class, number of objects, memory size in bytes, and fully qualified class names are printed. VM internal class names are printed with '*' prefix. If the live suboption is specified, only live objects are counted.

$ ./jmap -histo:live 5483

num #instances #bytes class name

----------------------------------------------

1: 59382 15091096 [B

2: 55619 8086328 <constMethodKlass>

3: 55619 7575048 <methodKlass>

4: 5214 5631224 <constantPoolKlass>

5: 7975 5152416 [I

6: 86854 4676400 <symbolKlass>

7: 5214 4162160 <instanceKlassKlass>

8: 32471 3946768 [C

9: 4444 3399072 <constantPoolCacheKlass>

10: 46368 2225664 java.util.HashMap

11: 46700 1739056 [Ljava.util.HashMap$Entry;

12: 70997 1703928 com.tc.object.ObjectID

13: 176 1655976 [J

14: 3333 1529648 <methodDataKlass>

15: 24404 1171392 com.tc.objectserver.managedobject.ManagedObjectImpl

16: 7457 1075912 [S

17: 33468 1070976 java.lang.String

18: 2247 1046888 [Ljava.lang.Object;

19: 21495 859800 com.tc.objectserver.persistence.db.TCPersistableMap

20: 26677 853664 com.sleepycat.je.tree.LN

21: 25185 805920 java.util.concurrent.ConcurrentHashMap$HashEntry

22: 44700 715200 java.util.HashMap$EntrySet

23: 15918 636720 com.tc.objectserver.managedobject.ConcurrentDistributedMapManagedObjectState

24: 4 589888 [Lorg.h2.util.CacheObject;

25: 5638 586352 java.lang.Class

26: 8285 404928 [[I

27: 5576 356864 com.tc.objectserver.managedobject.ConcurrentDistributedServerMapManagedObjectState

28: 11086 354752 java.util.HashMap$Entry

29: 790 287936 [Ljava.lang.String;

30: 395 230680 <objArrayKlassKlass>

Example 5:

Dumps the Java heap in hprof binary format to filename. The live suboption is optional. If specified, only the live objects in the heap are dumped. To browse the heap dump, you can use jhat (Java Heap Analysis Tool) to read the generated file.

Step 1: Genrerate Heap Profiler file using jmap.

$ ./jmap -dump:live,format=b,file=heap.hprof 10265

Dumping heap to /Optional/Oracle/Middleware/jdk1.6.0_26/bin/heap.hprof ...

Heap dump file created.

Step 2: Browse using java heap analyzer.

$ ./jhat heap.hprof

Reading from heap.hprof...

Dump file created Fri Jul 20 06:33:42 EDT 2012

Snapshot read, resolving...

Resolving 1681302 objects...

Chasing references, expect 336 dots................................................................................................................................................................................................................................................................................................................................................

Eliminating duplicate references................................................................................................................................................................................................................................................................................................................................................

Snapshot resolved.

Started HTTP server on port 7000

Server is ready.

Step 3: View the list of live objects and packages using browser.

About Jhat:

The jhat command parses a java heap dump file and launches a webserver. jhat enables you to browse heap dumps using your favorite webbrowser.

Note:

There are several ways to generate a java heap dump:

->Use jmap -dump option to obtain a heap dump at runtime;

-> Use jconsole option to obtain a heap dump via HotSpotDiagnosticMXBean at runtime;

-> Heap dump will be generated when OutOfMemoryError is thrown by specifying -XX:+HeapDumpOnOutOfMemoryError VM option;

Use hprof.

3.Java Information:

This command used to print the System properties and VM properties.YahoOOO!! Wonderful Utility!! :)

$ ./jinfo 10265

Attaching to process ID 10265, please wait...

Debugger attached successfully.

Server compiler detected.

JVM version is 20.1-b02

Java System Properties:

java.vendor = Sun Microsystems Inc.

org.xml.sax.parser = weblogic.xml.jaxp.RegistryParser

sun.java.launcher = SUN_STANDARD

com.sun.xml.ws.api.streaming.XMLStreamReaderFactory.woodstox = true

sun.management.compiler = HotSpot 64-Bit Tiered Compilers

os.name = Linux

sun.boot.class.path = /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/resources.jar:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/rt.jar:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/sunrsasign.jar:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/jsse.jar:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/jce.jar:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/charsets.jar:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/modules/jdk.boot.jar:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/classes

java.vm.specification.vendor = Sun Microsystems Inc.

java.runtime.version = 1.6.0_26-b03

weblogic.Name = AdminServer

user.name = thiru

user.language = en

java.naming.factory.initial = weblogic.jndi.WLInitialContextFactory

sun.boot.library.path = /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64

wlw.testConsole = false

wlw.iterativeDev = false

java.version = 1.6.0_26

user.timezone = US/Eastern

sun.arch.data.model = 64

javax.rmi.CORBA.UtilClass = weblogic.iiop.UtilDelegateImpl

java.endorsed.dirs = /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/endorsed

vde.home = /Optional/Oracle/Middleware/user_projects/domains/perf_r2/servers/AdminServer/data/ldap

sun.cpu.isalist =

sun.jnu.encoding = UTF-8

file.encoding.pkg = sun.io

wlw.logErrorsToConsole = false

file.separator = /

java.specification.name = Java Platform API Specification

java.class.version = 50.0

weblogic.home = /Optional/Oracle/Middleware/wlserver_10.3/server

user.country = US

com.sun.xml.ws.api.streaming.XMLStreamWriterFactory.woodstox = true

java.home = /Optional/Oracle/Middleware/jdk1.6.0_26/jre

platform.home = /Optional/Oracle/Middleware/wlserver_10.3

java.vm.info = mixed mode

os.version = 2.6.18-238.19.1.el5

org.omg.CORBA.ORBSingletonClass = weblogic.corba.orb.ORB

path.separator = :

java.vm.version = 20.1-b02

java.protocol.handler.pkgs = weblogic.net|weblogic.utils|weblogic.utils|weblogic.utils

java.awt.printerjob = sun.print.PSPrinterJob

java.security.policy = /Optional/Oracle/Middleware/wlserver_10.3/server/lib/weblogic.policy

sun.io.unicode.encoding = UnicodeLittle

java.naming.factory.url.pkgs = weblogic.jndi.factories:weblogic.corba.j2ee.naming.url:weblogic.jndi.factories:weblogic.corba.j2ee.naming.url

user.home = /home/grd

com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace = true

wls.home = /Optional/Oracle/Middleware/wlserver_10.3/server

java.specification.vendor = Sun Microsystems Inc.

org.xml.sax.driver = weblogic.xml.jaxp.RegistryXMLReader

java.library.path = /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64/server:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/amd64:/Optional/Oracle/Middleware/jdk1.6.0_26/jre/../lib/amd64:/Optional/Oracle/Middleware/patch_wls1034/profiles/default/native:/Optional/Oracle/Middleware/patch_ocp360/profiles/default/native:/Optional/Oracle/Middleware/wlserver_10.3/server/native/linux/x86_64:/Optional/Oracle/Middleware/wlserver_10.3/server/native/linux/x86_64/oci920_8:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

java.vendor.url = http://java.sun.com/

java.vm.vendor = Sun Microsystems Inc.

java.runtime.name = Java(TM) SE Runtime Environment

sun.java.command = weblogic.Server

java.class.path = /Optional/Oracle/Middleware/patch_wls1034/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/Optional/Oracle/Middleware/patch_ocp360/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/Optional/Oracle/Middleware/jdk1.6.0_26/lib/tools.jar:/Optional/Oracle/Middleware/wlserver_10.3/server/lib/weblogic_sp.jar:/Optional/Oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar:/Optional/Oracle/Middleware/modules/features/weblogic.server.modules_10.3.4.0.jar:/Optional/Oracle/Middleware/wlserver_10.3/server/lib/webservices.jar:/Optional/Oracle/Middleware/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/Optional/Oracle/Middleware/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/Optional/Oracle/Middleware/wlserver_10.3/common/derby/lib/derbyclient.jar:/Optional/Oracle/Middleware/wlserver_10.3/server/lib/xqrl.jar

java.vm.specification.name = Java Virtual Machine Specification

java.vm.specification.version = 1.0

javax.rmi.CORBA.PortableRemoteObjectClass = weblogic.iiop.PortableRemoteObjectDelegateImpl

sun.cpu.endian = little

sun.os.patch.level = unknown

java.io.tmpdir = /tmp

java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi

os.arch = amd64

java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment

java.ext.dirs = /Optional/Oracle/Middleware/jdk1.6.0_26/jre/lib/ext:/usr/java/packages/lib/ext

user.dir = /Optional/Oracle/Middleware/user_projects/domains/perf_r2

weblogic.ext.dirs = /Optional/Oracle/Middleware/patch_wls1034/profiles/default/sysext_manifest_classpath:/Optional/Oracle/Middleware/patch_ocp360/profiles/default/sysext_manifest_classpath

line.separator =java.vm.name = Java HotSpot(TM) 64-Bit Server VM

javax.xml.soap.MessageFactory = weblogic.webservice.core.soap.MessageFactoryImpl

weblogic.management.discover = true

javax.management.builder.initial = weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder

file.encoding = UTF-8

org.omg.CORBA.ORBClass = weblogic.corba.orb.ORB

javax.xml.rpc.ServiceFactory = weblogic.webservice.core.rpc.ServiceFactoryImpl

com.sun.xml.ws.api.BindingID.SOAP_12.canGenerateWsdl = true

weblogic.classloader.preprocessor = weblogic.diagnostics.instrumentation.DiagnosticClassPreProcessor

weblogic.ProductionModeEnabled = true

java.specification.version = 1.6

VM Flags:

-Xms256m -Xmx512m -XX:MaxPermSize=256m -Dweblogic.Name=AdminServer -Djava.security.policy=/Optional/Oracle/Middleware/wlserver_10.3/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -da -Dplatform.home=/Optional/Oracle/Middleware/wlserver_10.3 -Dwls.home=/Optional/Oracle/Middleware/wlserver_10.3/server -Dweblogic.home=/Optional/Oracle/Middleware/wlserver_10.3/server -Dweblogic.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=/Optional/Oracle/Middleware/patch_wls1034/profiles/default/sysext_manifest_classpath:/Optional/Oracle/Middleware/patch_ocp360/profiles/default/sysext_manifest_classpath

4.HPROF Utility:

HPROF can collect CPU usage information by injecting code into every method entry and exit, keeping track of exact method call counts and the time spent in each method. This uses Byte Code Injection (BCI) . Following is part of the output collected from a run of the javac compiler.

This utility will help developers to fine tune their program,if they used it effectively :)

$ ./javac -J-agentlib:hprof=cpu=times Hello.java

CPU TIME (ms) BEGIN (total = 103099259) Fri Oct 22 12:21:23 2004

rank self accum count trace method

1 5.28% 5.28% 1 308128 com.sun.tools.javac.Main.compile

2 5.16% 10.43% 1 308127 com.sun.tools.javac.main.Main.compile

3 5.15% 15.58% 1 308126 com.sun.tools.javac.main.Main.compile

4 4.07% 19.66% 1 308060 com.sun.tools.javac.main.JavaCompiler.compile

5 3.90% 23.56% 1 306652 com.sun.tools.javac.comp.Enter.main

6 3.90% 27.46% 1 306651 com.sun.tools.javac.comp.Enter.complete

7 3.74% 31.21% 4 305626 com.sun.tools.javac.jvm.ClassReader.listAll

8 3.74% 34.95% 18 305625 com.sun.tools.javac.jvm.ClassReader.list

9 3.24% 38.18% 1 305831 com.sun.tools.javac.comp.Enter.classEnter

10 3.24% 41.42% 1 305827 com.sun.tools.javac.comp.Enter.classEnter

11 3.24% 44.65% 1 305826 com.sun.tools.javac.tree.Tree$TopLevel.accept

12 3.24% 47.89% 1 305825 com.sun.tools.javac.comp.Enter.visitTopLevel

13 3.23% 51.12% 1 305725 com.sun.tools.javac.code.Symbol.complete

14 3.23% 54.34% 1 305724 com.sun.tools.javac.jvm.ClassReader.complete

15 3.23% 57.57% 1 305722 com.sun.tools.javac.jvm.ClassReader.fillIn

16 1.91% 59.47% 16 305611 com.sun.tools.javac.jvm.ClassReader.openArchive

17 1.30% 60.78% 330 300051 java.lang.ClassLoader.loadClass

18 1.28% 62.06% 330 300050 java.lang.ClassLoader.loadClass

19 1.22% 63.28% 512 300695 java.net.URLClassLoader.findClass

20 1.21% 64.48% 512 300693 java.net.URLClassLoader$1.run

21 1.09% 65.57% 14516 305575 java.util.zip.ZipFile$3.nextElement

22 0.98% 66.55% 14516 305574 java.util.zip.ZipFile$3.nextElement

23 0.96% 67.52% 1 304560 com.sun.tools.javac.main.JavaCompiler.instance

24 0.96% 68.48% 1 304559 com.sun.tools.javac.main.JavaCompiler.<init>

25 0.71% 69.19% 256 302078 java.net.URLClassLoader.access$100

This document can help some one to explore about various java executable that would be useful for developers, performance engineers and JavaEE server administrators.

No comments:

Post a Comment