The document summarizes Java development tools including:
- Compilation tools like javac and jar for compiling and packaging Java code
- Execution tools like java for running compiled code with options like -classpath and -jar
- JVM monitoring and troubleshooting tools like jps, jstack, jstat, jmap, jhat and jvisualvm
- Eclipse is mentioned as the official Java IDE but other options like IntelliJ and NetBeans are also good choices
- Exercises are provided to use the tools on sample code projects and debugging code
5. Exercises
Compile a bunch of .java 鍖les and output to
classes directory
Create jar 鍖le
Write main class, manifest-鍖le
Create jar 鍖le
Create another two jar 鍖les, and try Class-
Path
8. JVM Heap
Young Generation Eden Space C
A
B
from to
Old Generation Tenured Space
Permanent
Generation
class
A
class
B
class
C Permanent Space class
D
class
E
class
F
9. JVM Heap
GC1
B
Young Generation Eden Space C
to from
Old Generation Tenured Space
Permanent
Generation
class
A
class
B
class
C Permanent Space class
D
class
E
class
F
10. JVM Heap
GC1 GC2
Young Generation Eden Space
from to
Old Generation Tenured Space B
Permanent
Generation
class
A
class
B
class
C Permanent Space class
D
class
E
class
F
16. jps
List all JVM instances
Compared with ps -elf | grep java
jstack
Print thread stack dump of a JVM instance
Similar as pstack and gstack
jstat
JVM statistics monitoring
http://docs.oracle.com/javase/1.5.0/docs/
tooldocs/share/jstat.html
17. jmap
Dump all JVM objects
jmap -dump:live,format=b,鍖le=<鍖lename>
jhat
Analyze dump 鍖le generated by jmap
Start an http server where to connect to show analysis result
mat
Memory Analyzer
Dump 鍖le analysis tool based on Eclipse
More ef鍖cient and be able to analyze really large dump 鍖le
jvisualvm
Originated in NetBeans
All-in-one tuning and troubleshooting tool
24. Homework
Apply all the tools to AddressBook project
You may skip compilation and packaging
tools
You must execute your compiled binary
from CLI using java
Tuning and troubleshooting tools are
mandatory