Java Basic Training     III. Tool Matters
Compilation and  Packaging
javac  -classpath/-cp  -d  -source/-target  -encodingjar  Behaves similar as “tar”  -m manifest-file
Manifest-fileMETA-INF/MANIFEST.MFManifest-Version: 1.0Created-By: 1.6.0 (Sun Microsystems Inc.)Main-Class: c.e.m.j.MainClas...
ExercisesCompile a bunch of .java files and output to“classes” directoryCreate jar fileWrite “main” class, manifest-fileCreat...
Execution
java   -classpath/-cp   -jar   -client/-server   -d32/-d64   -D<name>=<value>   -X          -Xms<size>          -Xmx<size>...
JVM HeapYoung Generation                           Eden Space   C                                                         ...
JVM Heap                   GC1                                                                               BYoung Genera...
JVM Heap                   GC1              GC2Young Generation                             Eden Space                    ...
JVM Total MemoryJVM heapThread execution stackJVM itself
JVM Total MemoryJVM heapThread execution stackJVM itself                         think about -Xmx<size>
-XX-XX:DisableExplicitGC-XX:UseParallelGC-XX:UseParallelOldGC-XX:MaxPermSize=<size>http://www.oracle.com/technetwork/java/...
ExercisesRun compiled classRun packed jar file by specifying classpathRun packed jar file using “-jar”Try different -XX opti...
Tuning & Troubleshooting
jps   List all JVM instances   Compared with “ps -elf | grep java”jstack   Print thread stack dump of a JVM instance   Sim...
jmap       Dump all JVM objects       jmap -dump:live,format=b,file=<filename>jhat       Analyze dump file generated by “jmap...
ExercisesTry all the tools mentioned one by one
The IDE
What Makes a Language   Widely Accepted Simple & Stupid Off-the-shelf libraries Powerful IDE
Official One - EclipseWorkspace   TemplateEditor      Working setKeymap      DebugFormatter
Other Good ChoicesIDEANetBeansAnymore?
ExercisesRewrite Workable, Resource, Designer, TesterTry to set up working setSet a breakpoint, and debug
HomeworkApply all the tools to AddressBook project  You may skip compilation and packaging  tools  You must execute your c...
Upcoming SlideShare
Loading in …5
×

3 tool matters

593 views
456 views

Published on

a series of basic java training courses, this is the third one

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
593
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • 3 tool matters

    1. 1. Java Basic Training III. Tool Matters
    2. 2. Compilation and Packaging
    3. 3. javac -classpath/-cp -d -source/-target -encodingjar Behaves similar as “tar” -m manifest-file
    4. 4. Manifest-fileMETA-INF/MANIFEST.MFManifest-Version: 1.0Created-By: 1.6.0 (Sun Microsystems Inc.)Main-Class: c.e.m.j.MainClass-Path: lib/a.jar lib/b.jar
    5. 5. ExercisesCompile a bunch of .java files and output to“classes” directoryCreate jar fileWrite “main” class, manifest-fileCreate jar fileCreate another two jar files, and try “Class-Path”
    6. 6. Execution
    7. 7. java -classpath/-cp -jar -client/-server -d32/-d64 -D<name>=<value> -X -Xms<size> -Xmx<size> -Xss<size> -XX
    8. 8. JVM HeapYoung 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. 9. JVM Heap GC1 BYoung 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. 10. JVM Heap GC1 GC2Young 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
    11. 11. JVM Total MemoryJVM heapThread execution stackJVM itself
    12. 12. JVM Total MemoryJVM heapThread execution stackJVM itself think about -Xmx<size>
    13. 13. -XX-XX:DisableExplicitGC-XX:UseParallelGC-XX:UseParallelOldGC-XX:MaxPermSize=<size>http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
    14. 14. ExercisesRun compiled classRun packed jar file by specifying classpathRun packed jar file using “-jar”Try different -XX options
    15. 15. Tuning & Troubleshooting
    16. 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. 17. jmap Dump all JVM objects jmap -dump:live,format=b,file=<filename>jhat Analyze dump file generated by “jmap” Start an http server where to connect to show analysis resultmat Memory Analyzer Dump file analysis tool based on Eclipse More efficient and be able to analyze really large dump filejvisualvm Originated in NetBeans All-in-one tuning and troubleshooting tool
    18. 18. ExercisesTry all the tools mentioned one by one
    19. 19. The IDE
    20. 20. What Makes a Language Widely Accepted Simple & Stupid Off-the-shelf libraries Powerful IDE
    21. 21. Official One - EclipseWorkspace TemplateEditor Working setKeymap DebugFormatter
    22. 22. Other Good ChoicesIDEANetBeansAnymore?
    23. 23. ExercisesRewrite Workable, Resource, Designer, TesterTry to set up working setSet a breakpoint, and debug
    24. 24. HomeworkApply 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

    ×