Search code examples
javamacosnetbeansweb3-java

How to add web3j to my project in NetBeans


I'm trying to use web3j (https://github.com/web3j/web3j) and I can't figure out how.

I know Java (I've developed android apps in android studio) but not netbeans. Though I haven't touched Java in forever. I am familiar with building and interacting with Ethereum contracts from the command line.

I need to connect to an Ethereum contract through java, so I googled around for a while and found web3j. However... I can't figure out how to actually use/install/require it. There's a sample project, but I'm not sure how to import that to netbeans. And when I google "connect to ethereum with java" or something along those lines all the articles gloss over the web3j part and just assume it's already setup.

How do I add this library to my Java project in netbeans?


Solution

  • In Netbeans, create a new "Maven Java Project".

    In the file pom.xml, simply add the following code. This will make the "include"

    <dependency>
      <groupId>org.web3j</groupId>
      <artifactId>core</artifactId>
      <version>3.2.0</version>
    </dependency>