Sending an Ether Transfer Transaction from One Account to Another in Web3j

To transfer ether from one account to another, a transaction must be sent to the ethereum network. The easiest way to achieve this within your java application is to use the useful Transfer class of web3j.

The below example transfers 1 ether from the seed phrase account to the recipientAddress account:

//Connect to node
//Defaults to http://localhost:8545
Web3j web3 = HttpService());  // defaults to http://localhost:8545/

//Generate wallet credentials from a mnemonic seed phrase
Credentials credentials = WalletUtils.loadBip39Credentials("password", "mnemonic");

//The address that the ether should be transferred to
String recipientAddress = "0xF0f15Cedc719B5A55470877B0710d5c7816916b1";

//The ether amount to transfer.
BigDecimal amountInEther = BigDecimal.valueOf(1.0);

//Send the transfer transaction.
//Unit conversion is handled automatically and this method blocks until the transaction has been mined.
TransactionReceipt transactionReceipt = Transfer.sendFunds(
        web3, credentials, recipientAddress,
        amountInEther, Convert.Unit.ETHER).send();

Note that there are multiple ways to generate wallet credentials. For more imformation, check out Managing an Ethereum Account with Java and Web3j.