-1

Getting error class not found exception on running java code package name is com.personal.cucumber.Maven_Try Class name is Try_Class

POM attached below and note JDK is set in Java compiler

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.personal.cucumber</groupId>
<artifactId>Maven_Try</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Maven_Try</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        <addClasspath>true</addClasspath>
                        <mainClass>com.personal.cucumber.Maven_Try.Try_Class</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>../conf/</Class-Path>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

  • What command are you actually starting? How does your source tree liook like? If you open the jar does it contain the class? – eckes Sep 21 '16 at 18:29

1 Answers1

0

If you came across the error:Not able to run java main method using maven do this it worked for me: Reason for the error: The reason for this error is the jar file or dependency to run a maven project is not installed correctly.

Solution for the error: Go to the project folder (eg: D:\office\OIA-service-app) in the address bar of computer type command "cmd" and press enter. In the command prompt type command "mvn clean install"[image][1] make sure you have the internet connection.