0

Goal & Problem

I have created a Java program in IntelliJ. I built it as a .jar file following the instructions here. When I try to run it, it gives me the following output:

Parameters: archive-name [archive-type]

no main manifest attribute

Note: I have tried to run it in two ways. The first way is through the IDE, and the second way is through command line using the following command: java -jar jarname.jar. Both ways have the same result.


What I have tried

Here is my project.

To determine the point of error, I started over with a simple Hello World program, here is my code:

public class Producer {
    public static void main(String[] args) throws Exception{
        System.out.println("Hello World!");
    }
}

and here is my Maven:

<repositories>
    <repository>
        <id>confluent</id>
        <url>http://packages.confluent.io/maven/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>io.confluent</groupId>
        <artifactId>kafka-avro-serializer</artifactId>
        <version>3.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.11</artifactId>
        <version>0.10.2.1-cp1</version>
    </dependency>
    <dependency>
        <groupId>org.rxtx</groupId>
        <artifactId>rxtx</artifactId>
        <version>2.1.7</version>
    </dependency>
</dependencies>

Note: I was unable to build it without the repositories and dependencies above in my Maven, so this may have something to do with the problem, but I can't imagine how or why.

Any advice would be welcome.

Thanks in advance.

Community
  • 1
  • 1
Tyler
  • 67
  • 7

1 Answers1

1

The issue was caused by the files residing in the wrong locations (resources in source roots, sources in test source roots), this animation explains how to fix it.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904