I've added following into dependencies section of my pom.xml:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4.1</version>
<scope>test</scope>
</dependency>
But when I add the 1st line of "Quick start guide" (http://hc.apache.org/httpcomponents-client-4.4.x/quickstart.html):
CloseableHttpClient httpclient = HttpClients.createDefault();
IntelliJ IDEA highlights "HttpClients" and tells me:
Cannot resolve symbol 'HttpClients'
It looks like I have mistake with configuration. What exactly is wrong? please advise how to add support for HttpClients into the project?
Thanks!
P.S. Learned a bit more, looks like "" is redundant and wrong for this case, I removed it but that didn't help: still non-compilable.
EDIT: If I put cursor to 'HttpClients' and hit "Alt-enter" the pop-up doesn't contain any class to import. See screenshot:
It looks like my IntelliJ had issues with caching, cleaning cache with following re-importing of the project helped.
I found tips on that here: IntelliJ inspection gives "Cannot resolve symbol" but still compiles code
P.S. Though few other project were broken as a result of this action. Looks like I need to keep learning :)
Download the jar file from
https://jar-download.com/artifacts/org.apache.httpcomponents/httpclient/4.5.6/source-code
Extract the .jar file name httpclient-4.5.6.jar. Form a directry name lib under your project and import this .jar file to it. Right click your .jar file and click addtolibrary.
Related
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.stack.imgur.com/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
I have a project that I'm trying to play around with the Immutables Criteria: https://immutables.github.io/criteria.html
I added the following to my pom.xml:
<dependency>
<groupId>org.immutables</groupId>
<artifactId>criteria-inmemory</artifactId>
<version>2.8.2</version>
</dependency>
Everything seemed fine. However, I am having some issues getting things imported and working. I have no issues with Immutables.Value that works fine. When I import Criteria Eclipse complains about:
The type org.immutables.criteria.Criteria is not accessible
So I tried adding the module to my module-info.java as follows:
requires org.immutables.criteria-common;
Also tried:
requires org.immutables.criteria-inmemory;
I'm using Eclipse suggestions to auto-complete the module name because I don't really know what the module name should be but, when I add the above Eclipse says there is a syntax error with the "-" in the requires statement. So at this point I am kinda stuck! If anyone has any suggestions I would love to hear them!
Thanks!!
I was able to track down the issue with the Immutables Library and I posted the following issue: https://github.com/immutables/immutables/issues/1223
Basically, the library was creating an invalid Automatic-Module-Name tag in there pom.xml's when building the jar files. The values that we being set contained a "-" which is invalid.
Shoutout to #Naman for pointing me in the right direction! Thanks!
I am still wondering if it is possible to override the jar files module-name. It seems like it could be useful for users of a library to somehow override a libraries jar files module-name for situations like this.
I am getting an error with a project I am trying to build - and I have absolutely no idea what is going on :
I am bringing in this class :
import com.company.module.pojo.MyPojo;
Ok, that is straight forward, and in intelliJ, I can even cmd + click and go directly to that class, I KNOW it is there, and I know intelliJ knows it is there.
then I do a build... and I get this...
error: package com.company.module.pojo does not exist
What? Why? How is this happening? :(
I am tagging gradle in this question, as I am from the maven world, and this whole mess could be down to me not having a clue about gradle, I guess.
I know that this is usually caused by the class not existing (or a typo in the import) but I know that to be all in place, so I am stumped here.
Add it as a module dependency.
File
Project Structure
Project
Modules
Dependencies
Green plus sign on the right.
Choose correct directory
I am trying to run Mallet`s topic modelling but got the following error:
Couldn't open cc.mallet.util.MalletLogger resources/logging.properties file.
Perhaps the 'resources' directories weren't copied into the 'class' directory.
Continuing.
Exception in thread "main" java.lang.IllegalArgumentException: Trouble reading file stoplists\en.txt at cc.mallet.pipe.TokenSequenceRemoveStopwords.fileToStringArray(TokenSequenceRemoveStopwords.java:144) at cc.mallet.pipe.TokenSequenceRemoveStopwords.<init>(TokenSequenceRemoveStopwords.java:73) at LDA.TopicModel.main(TopicModel.java:23)
I have already added all the jar files! Could you please advise what is the problem here?
Thanks,
I received the first error, which it's able to continue from, as well.
But the actual exception that stops you seems to be that you don't have the MALLET stop words list in the right place. I downloaded their en.txt stopwords list to a specific location and gave it a direct path instead of "stoplists/en.txt", which worked.
Your english stop words file is missing (stoplists\en.txt). Either try downloading the jar files again, or just use maven which will make it easier for you to import in your java project. In the Maven POM file add:
<dependencies>
<dependency>
<groupId>cc.mallet</groupId>
<artifactId>mallet</artifactId>
<version>2.0.8</version>
</dependency>
....
</dependencies>
Latest version can be found here.
I wanted to code from this answer but i have error The import org.bouncycastle.openssl cannot be resolved The import org.bouncycastle.openssl cannot be resolved and i have no idea how coudl i repair this becouse other bouncycastle libs are detected correctly.
I will be grateful for any ideas whats wrong. Im using eclipse and i have instaled bouncycastle like in this instruction itcsoultions
In addition to the provider (a.k.a. bcprov) and lightweight API, you also need the PKIX API, which provides the openssl package.
Either download bcpkix-jdk15on-150.jar from BC downloads page (direct link) and drop it in the same directory of bcprov or add it to your maven dependencies with its coordinates:
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.50</version>
</dependency>
Whenever we get error saying "The import *** cannot be resolved", it means that there is problem with library. Here, bcprov-jdk jar is missing.
I did the following, and it worked for me!
1. Download bcprov-jdk15on-152.jar from https://www.bouncycastle.org/latest_releases.html
2. Right click on Project-->Properties-->Java Build Path-->Libraries tab--> Click on Add External JARs.. Select the path where you have the dowlnloaded bcprov-jdk15on-152.jar. Then click OK. That's it.