w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Unable to run Java program that imports org.apache.lucene.analysis.Analyzer

Your problem is that when you build the jars of your application, the maven dependences of Lucene (.jar files) are not included in your jars, that is, Java cannot find the Lucene's classes that your application use. I had the same issue with the same stack trace.

You should better use Maven to build your project.

What you have to do, is to build your sources with the dependences and then, your compiled application will include the Lucene's jars.

To do this, just add these lines of code in your .pom file of the Maven project

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                  <descriptorRefs>
                    
<descriptorRef>jar-with-dependencies</descriptorRef>
                  </descriptorRefs>    
               </configuration>
               <executions>
                  <execution>
                     <id>make-assembly</id>
                     <phase>package</phase>
                     <goals>                         
                       <goal>single</goal>
                     </goals>
                 </execution>
              </executions>
            </plugin>
        </plugins>
    </build>

Now, run your application: hadoop jar APP_NAME-jar-with-dependencies.jar

All the above will resolve your issue.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.