SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Java Basic Training
     III. Tool Matters
Compilation and
  Packaging
javac

  -classpath/-cp

  -d

  -source/-target

  -encoding


jar

  Behaves similar as “tar”

  -m manifest-file
Manifest-file

META-INF/MANIFEST.MF

Manifest-Version: 1.0

Created-By: 1.6.0 (Sun Microsystems Inc.)

Main-Class: c.e.m.j.Main

Class-Path: lib/a.jar lib/b.jar
Exercises
Compile a bunch of .java files and output to
“classes” directory

Create jar file

Write “main” class, manifest-file

Create jar file

Create another two jar files, and try “Class-
Path”
Execution
java

   -classpath/-cp

   -jar

   -client/-server

   -d32/-d64

   -D<name>=<value>

   -X

          -Xms<size>

          -Xmx<size>

          -Xss<size>

   -XX
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
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
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
JVM Total Memory


JVM heap

Thread execution stack

JVM itself
JVM Total Memory


JVM heap

Thread execution stack

JVM itself
                         think about -Xmx<size>
-XX

-XX:DisableExplicitGC

-XX:UseParallelGC

-XX:UseParallelOldGC

-XX:MaxPermSize=<size>

http://www.oracle.com/technetwork/java/
javase/tech/vmoptions-jsp-140102.html
Exercises


Run compiled class

Run packed jar file by specifying classpath

Run packed jar file using “-jar”

Try different -XX options
Tuning & Troubleshooting
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
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 result

mat

       Memory Analyzer

       Dump file analysis tool based on Eclipse

       More efficient and be able to analyze really large dump file

jvisualvm

       Originated in NetBeans

       All-in-one tuning and troubleshooting tool
Exercises



Try 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 - Eclipse


Workspace   Template

Editor      Working set

Keymap      Debug

Formatter
Other Good Choices


IDEA

NetBeans

Anymore?
Exercises


Rewrite Workable, Resource, Designer, Tester

Try to set up working set

Set a breakpoint, and debug
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

Weitere ähnliche Inhalte

Andere mochten auch (8)

JAVA AND ANDROID OS_PRESENTATION
JAVA AND ANDROID OS_PRESENTATIONJAVA AND ANDROID OS_PRESENTATION
JAVA AND ANDROID OS_PRESENTATION
 
Basic of Java Netbeans
Basic of Java NetbeansBasic of Java Netbeans
Basic of Java Netbeans
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Oop java
Oop javaOop java
Oop java
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

3 tool matters

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n