I'm trying to implement code from https://github.com/sstrickx/yahoofinance-api on Eclipse in Java. When I run the program, I'm getting a several lines of errors that are being printed on the console. When I click on the errors, it takes me to a window named "YahooFinance.class" on Eclipse that says "Source not found." It asks me to change the attached source. I have added the source to C:/Program Files/Java/jdk-11.0.11/lib/src.zip on my computer, but I'm still getting the same error. Any help would be greatly appreciated!
[Screenshot of error][1] [1]: https://i.sstatic.net/GZuL7.png
Edit: This is the code that I am trying to compile from source:
Stock stock = YahooFinance.get("INTC");
BigDecimal price = stock.getQuote().getPrice();
BigDecimal change = stock.getQuote().getChangeInPercent();
BigDecimal peg = stock.getStats().getPeg();
BigDecimal dividend = stock.getDividend().getAnnualYieldPercent();
stock.print();
My project is Maven-based and I have added this dependency to the pom.xml file:
<dependency>
<groupId>com.yahoofinance-api</groupId>
<artifactId>YahooFinanceAPI</artifactId>
<version>3.15.0</version>
</dependency>
After refreshing my project's Maven dependencies, like Kevin Hooke said to do, I am no longer getting the "Source not found" error. Thank all of you for your quick responses and help!
The source project you're trying to use is a Maven based project and provides instructions on how to include it as a dependency.
Create a new Maven project in Eclipse (or update your project to be Maven based, adding a pom.xml file, standard folder structures etc)
Edit your pom.xml file and add a dependency to the yahoofinance-api project:
<dependency>
<groupId>com.yahoofinance-api</groupId>
<artifactId>YahooFinanceAPI</artifactId>
<version>x.y.z</version>
</dependency>
Replace x.y.z with the version that you need to use
Refresh your project's Maven dependencies: right-click project, Maven -> Update Project