EdmondFrank's 时光足迹

この先は暗い夜道だけかもしれない それでも信じて進むんだ。星がその道を少しでも照らしてくれるのを。

Java Dev Tools and Debugging Notes

Jave Dev tools and Debugging Notes

  1. Java
    1. Maven
      1. use maven with proxy and skip tests:
      2. Structure
    2. JShell
    3. Javap
    4. Jar Files
      1. compile and package as a FAT-JAR
      2. differences between “java -cp” and “java -jar”
    5. Debugging
      1. Exec args:
      2. Jdb


Some notes about Java dev tools and debuggers


build lifecycle targets

  • validate: validate the project is correct and all necessary information is available
  • compile: compile the source code of the project
  • test: test the compiled source code using a suitable unit testing framework. There tests should not require the code be packaged or deployed
  • package: take the compiled code and package it in its distributable format, such as JAR
  • verify: run any checks on results of integration tests to ensure quality criteria are met
  • install: install the package into the local repository, for use as a dependency in other projects locally
  • deploy: done in the build environment, copies the final package to the remote repository for sharing with other developers and projects

use maven with proxy and skip tests:

-Dmaven.test.skip=true -Dhttps.proxyHost= -Dhttps.proxyPort=1081 -Dhttp.proxyHost= -Dhttp.proxyPort=1081


  1. Expected directory structure:
    • Java files are in src/main/java as well as src/test/java.
    • Resource files are under src/main/resources and src/test/resources.
  2. mvn archetype:generate: Generates a skeleton of a project based on your inputs (package name, versioning, project name, etc)
  3. Edit pom.xml and set the jdk version there..
  4. mvn package - compile, test, bundle.


Java REPL(Read Eval Print Loop) import after Java 9

  • /list -start - shows modules imported at startup.
  • /edit - edit that line in a new window.
  • /set editor “vi” - use vi instead of the default graphical edit pad.
  • /save abc.java - save current buffer to file.
  • /load abc.java - load from file into shell.
  • /-1 - execute last snippet.
  • /1 - execute first snippet.
  • /drop N - drop Nth snippet.
  • /vars - show only variables that were defined in snippets.
  • /types - show only classes that were defined in snippets.


javap TestDecompile.class - decompile .class file to human readable format. Does not show content of methods though. javap -c TestDecompile.class - show jvm bytecode in human readable -form, including methods.

Jar Files

These are zip files that have a META-INF folder with a Manifest.mf file inside.

compile and package as a FAT-JAR

<?xml version="1.0" encoding="UTF-8"?>
            <!--  get all project dependencies  -->
            <!--  MainClass in mainfest make a executable jar  -->
               <!--  bind to the packaging phase  -->

differences between “java -cp” and “java -jar”

  • There won’t be any difference in terms of performance.
  • java -cp: must specify the required classes and jar’s in the classpath for running a java class file.
  • java -jar: jvm finds the class that it needs to run from /META-INF/MANIFEST.MF file inside the jar file


  • jps - Shows all runnning java processes.
  • jvisualvm - If you have it, it shows the java processes on the system with details on threads, profiler etc.
  • debugging mode - Use these args to start a process in debugging mode

Exec args:


  • agentlib=jdwp - Load the jdwp agent, for debugging.
  • transport=dt_socket - for connecting a debugging client over the network.
  • server=y - this one is the server half of the debugging.
  • suspend=y - don’t start executing until a client debugger attaches.
  • address=7777 - port we listen on.


  • jdb -attach : attach debug process start with debugging mode.