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.
pom.xml
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>geth</artifactId>
<version>4.0.1</version>
</dependency>
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);
geth --port 3000 --networkid 1996 --nodiscover --datadir=./datadir --maxpeers=0 --rpc --rpcport 8585 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner, admin, txpool" console