-1

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?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Chris
  • 125
  • 1
  • 3
  • 12
  • 1
    The question looks offtopic. However, here's a hint: Netbeans is an IDE, it paints code in cool colors and allows you to jump between files. What you need is a tool for managing dependencies. Look out for build tools like Apache Maven or Gradle. Declare [web3j](https://mvnrepository.com/artifact/org.web3j/core/3.2.0) as dependency by adding it to the build definition. Then make sure it builds and compiles from the console. Then you can import it with Netbeans or Eclipse or whatever you want. – Andrey Tyukin Feb 11 '18 at 01:36
  • Did you read the `readme.rst`? It looks it has some instructions. – Yohannes Gebremariam Feb 11 '18 at 01:37
  • @YohannesGebremariam I did... it looks like it was an issue with my unfamiliarity with netbeans, rather than the library. thanks for the reply – Chris Feb 11 '18 at 01:58
  • @AndreyTyukin out of curiosity what do you think would have been a better place to post this, given that I wasn't sure where the issue was? I seldom post here since, on the rare occasion I can't figure it out myself, whatever I'm looking for is usually answered already... OR do you think, based on my situation at the time, I could have written the issue out better? – Chris Feb 11 '18 at 02:12
  • seriously!? down-votes? with an utter absence of constructive criticism as to why? Great community here... definitely a nice learning environment (-_-) ...I clearly stated I wasn't sure how to ask what I needed to. at least leave feedback on why you're down voting and how i can maybe avoid it in a similar situation later. – Chris Feb 11 '18 at 02:21
  • @Chris This [meta thread](https://meta.stackoverflow.com/questions/251134/where-can-i-ask-about-finding-a-tool-library-or-favorite-off-site-resource) here redirects to [Software Recommendations StackExchange](https://softwarerecs.stackexchange.com/help/on-topic). Quote from [here](https://meta.stackexchange.com/questions/199411/where-can-i-ask-a-question-about-finding-general-software-that-meets-certain-req): "Software Recommendations Stack Exchange accepts questions about general-purpose software, development tools and libraries, as well as more specialized software". – Andrey Tyukin Feb 11 '18 at 02:31
  • @Chris I guess that the downvotes were attracted mostly by the very long and very unprecise title. I didn't downvote anything, by the way ;) – Andrey Tyukin Feb 11 '18 at 02:32
  • @AndreyTyukin thanks! I definitely would never have even known that subdomain existed. It does seem a bit more appropriate for my question. much appreciated. – Chris Feb 11 '18 at 02:39
  • 1
    @Chris More appropriate: yes, but I can't tell you how long it would take to get any kind of reaction there: 14k questions vs 15Million questions on SO. You know, if you simply showed a little basic java code snippet with the most basic single line with web3j, and then posted compile errors, and stated clearly what you want in the title, you wouldn't have attracted any downvotes, and you would probably get the same answer in the end. This "software recomendation" question could be bent a little until it looks like an ordinary programming compile-error question, and everything would be fine. – Andrey Tyukin Feb 11 '18 at 02:55
  • @Chris And if you decide to ask on SRSE, check the "How to ask"-section there too: they also seem to have very specific rules for what constitutes a proper question. – Andrey Tyukin Feb 11 '18 at 02:59
  • @AndreyTyukin Thanks for the feedback! that makes sense. and yeah, i read their 'how to ask' section. It's pretty clear actually. I guess I just need to work on asking better questions lol... though when I can figure out how to ask what I need to know, I'm usually close enough to an answer to figure it out. I assumed the base site (SO) would be for more general questions since it's not specialized like say wordpress.stackoverflow. you live you learn. next time I'll look for a subdomain I guess. – Chris Feb 11 '18 at 03:29

1 Answers1

2

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>
  • ugh! knew it was gonna be something really basic that I was missing. This always happens when I switch languages/IDEs.... I was spinning up a basic java project and couldn't figure out why I couldn't add the dependency to the build file.. Thanks so much! I waisted like 3 hours on this today lol – Chris Feb 11 '18 at 01:56