Ben Chuanlong Du's Blog

It is never too late to learn.

Debugging Tools for Java

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

arthas

arthas

JDK commands

Thread dump: jstack jvm_pid > (use -F if not responding)

Memory dump: jmap -dump:live,format=b,file=.hprof jvm_pid

Heap status: jmap -heap jvm_pid

GC status: jstat …

Misc Tips on Java

Tips and Traps

  1. Use == (instead of the method Object.equals) to compare objects is a common and tricky mistake for beginner.

  2. You cannot define an abstract static method. This is because "abstract" means that no functionality is implemented while "static" means that functionality exists even there is no object. The two conflict in concept.

Call Java Code Using JPype from Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

JPype is easy and intuitive to use. It is the most popular Java interface for Python currently.

import os
import sys
from pathlib import Path
import jpype


jpype.addClassPath("/path/to …

Tips on Maven

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

The Central Repository

$HOME/.m2

maven: shade plugin, scala compile plugin, exclude manifest files, ...

import as maven project ...

find an updated version of scala archetype for maven

mvn package  
mvn clean …

Java PPA for Ubuntu

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

sudo add-apt-repository ppa:webupd8team/java

If you are behind a firewall and has to communicate to the internal via a proxy, you can first export the environment vairables http_proxy and https_proxy …

Collections in Java

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Oracel Java Tutorial on Collections

ArrayList

  1. You can point an element of Array or ArrayList to null, but remember that a null reference cannot invoke any method. For example, if you …