I am using web3j and Geth and created a private network. However, I want to do the mining manually whenever required, since don't want to jam the server when I am in the development phase. For that, I found JsonRpc2_0Geth update in web3j and used it. However, mining does not start. Please help me where I am going wrong.



Then, i called the Geth aPI through my java file as follows:

static public Web3j web3j = Web3j.build(new HttpService("<geth ip>:<port>"));
static public JsonRpc2_0Geth geth = new JsonRpc2_0Geth(new HttpService("<geth ip>:<port>"));
  • geth.minerStart(1000); asks miner to use 1000 threads, you can try following troubleshooting. 1. Try 1 thread geth.minetStart(1) and try start mining from console. Do any of these work ? Dec 5 '18 at 3:38
  • mining from geth console works. Not from the java file though. How can i troubleshoot for java ? Dec 5 '18 at 4:16
  • Does it work with geth.minerStart(1) Dec 5 '18 at 4:19
  • And what is the full command line that is used to start geth ? Dec 5 '18 at 4:21
  • No, geth.minerStart(1) did not work for me. The way i used it is mentioned in my original draft. The way i started geth node is : geth --port 3000 --networkid 1996 --nodiscover --datadir=./datadir --maxpeers=0 --rpc --rpcport 8585 --rpcaddr --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner, admin, txpool" console Dec 5 '18 at 5:27

Posting to RPC URL is a way to start mining from any language


I.e. post this data to RPC URL.

Command line example is :

curl -X POST --data '{"jsonrpc":"2.0","method":"miner_start","params":[4],"id":74}' localhost:8545


This page has example of sending a POST request from Java.


  • I am trying this solution. Thanks for the response . Will update you soon. Dec 6 '18 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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