I use web3j to fetch information from ethereum blockchain,

public static void main(String[] args) throws InterruptedException {
    Web3j web = Web3j.build(new HttpService(""));
    Observable<EthBlock> observable = web.blockObservable(true);
    Subscription subscription = observable.subscribe(System.out::println);
    System.out.println("main say good bye.");
    // jvm not exit!

As mentioned in the official document, subscriptions should always be cancelled when no longer required. So I call unsubscribe(), but the JVM not exit. How can I quit properly?

1 Answer 1


Although your code worked for me, you can ensure a proper exit by calling:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.