If you are wondering how to install web3j on your machine then look no further. This post will walk you through everything you need to know about the various ways you can get web3j into your project in a few easy steps.
Web3j is released on Maven at Maven Repository and can therefore be added as a dependency in any project that uses practically any build tool known for Java development. Some examples include: Maven
To add web3j to a maven project you can include the following in your pom.xml file:
Web3j as a project is divided into different modules. Each module is responsible for a functional domain such as core functionality, encoding and decoding etc… Every module is configured to be released individually. You may have noticed in the above example that the core module is referenced. Based on the needs of your project each module can be pulled individually from Maven. The full list of modules is available on the Maven Repository.
Injected via the plugin The Web3j Gradle plugin allows you to compile Solidity smart contracts and generate Java wrappers. These wrappers are java classes that make it easy for developers to deploy or interact with their on-chain smart contracts. The plugin also injects web3j into the user’s project making it easy to interact with Ethereum.
To add the plugin to your project via Gradle add the following in the plugin section inside gradle.build file:
Using the Web3j-CLI Another great way to use web3j is through the command-line interface. The CLI is bundled with great functionality aimed to smoothen the development process by providing a lot of the scaffolding required to get started. To install the CLI you will need to paste the following line on the terminal for Unix based systems:
curl -L get.web3j.io | sh
Windows in Powershell Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/web3j/web3j-installer/master/installer.ps1'))
Using the command line interface, a user can generate a wallet or a new project or even set up the whole backend for an ERC20 Token. More on that at Command Line Tools - Web3j.
Have any questions or comments? We’d love to hear from you! If you want to find out more about blockchain, its growth, and newest developments, then check our dev blog or listen to our enlightening Web3 Innovators podcast.