0

I am creating an executable jar file for my project and created the MANIFEST.mf file. I have changed the location of manifest file to src/main/resources Although the manifest.mf file is auto generated by intellij, it is still showing me error with Main-Class attribute as 'cannot resolve class'.

My main class look like this:

package runner;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)

@CucumberOptions(
        strict=true,
        monochrome=false,
        features = {"src/test/java/features/ALogin.feature",},

        glue = {"steps"},
       plugin= {
                "html:target/site/cucumber-html",
                "json:target/cucumber1.json"}
)
public class TestRunner {
    public static void main(String[] args){

        String[] arguments={"--glue", "steps"};
        cucumber.api.cli.Main.main(arguments);
        SecurityManager manager = new IgnoreExitCall();
        System.setSecurityManager(manager);
        try {
            cucumber.api.cli.Main.main(arguments);
        } catch (SecurityException s) {
            System.out.println("Ignore exit");
        }
    }
}

My MANIFEST.mf like look like this:

Manifest-Version: 1.0
Main-Class: runner.TestRunner

on hovering over Main-Class, it says cannot resolve class 'runner.TestRunner'.

My pom.xml looks like this:

</plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
            <execution>
                <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <mainClass>
                                    runner.TestRunner
                                </mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>
Svirin
  • 564
  • 1
  • 7
  • 20
  • Can you clarify the exact problem? Is it only a message about unresolved class? If you provide a sample project to check there are better chances to get help. – Andrey Sep 23 '20 at 08:33
  • No, its not only about the message, while executing the jar file, i am getting the same error "Cannot resolve class: runner.TestRunner". I am assuming it is because the same error i am getting inside MANIFEST.mf file. i'll try if i am able to provide you with a sample project. Till then, let me know if the above information is helpful to you. – shaifali saxena Sep 23 '20 at 11:05

0 Answers0