user1 user1 - 2 months ago 31
Java Question

why some imports cannot be resolved?

I'm new to java , i tried to use word net for senitment analysis .
when i used class of wordnet , i got the following failure in importing

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.lucene.analysis.en.EnglishMinimalStemmer;
import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileListener;
import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileTracker;
import org.apache.stanbol.enhancer.engines.sentiment.api.LexicalCategoryClassifier;
import org.apache.stanbol.enhancer.engines.sentiment.api.SentimentClassifier;
import org.apache.stanbol.enhancer.engines.sentiment.util.WordSentimentDictionary;
import org.apache.stanbol.enhancer.nlp.pos.LexicalCategory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;


all the above imports cannot be resolved like
org.apache.felix
,
org.apache.lucene
,
org.apache.stanbol
,
org.osgi


enter image description here

Answer

This is because your compiler is not able to find the necessary packages and or libraries that are needed to resolve these imports. These packages must be included in your class path. For example all of the errors regarding

org.apache.felix.scr.annotations.x

can be resolved after downloading the latest .jar from https://mvnrepository.com/artifact/org.apache.felix/org.apache.felix.scr.annotations/1.11.0

Follow these steps to include jar files in your class path. -

  • Drag the required jar file from your download directory to the src directory of your project in eclipse
  • Right click on the jar file, Select Build Path and then select Add To Build Path option.
  • A dialogue box will appear asking you to link all files in the jar file, just stick with the defaults and hit OK.
  • You are done now, all your errors regarding imports will be resolved.
Comments