Is there a anyway to add static code block into java class using javapoet library
static { // whatever code is needed for initialization goes here }
Use TypeSpec.Builder::addStaticBlock. See this test case for an example.