I made a maven project and I’m trying to compile my jar file and code to test it on inputs. Here is my project structure.
However, when I run this command
java -cp SSC01-1.0-SNAPSHOT.jar org.example.Main
where SSC01-1.0-SNAPSHOT.jar is my jar file,
I get a ClassNotFoundException…..
so what am I doing wrong? is my class name wrong?
I’ve even edited my pom.xml file accordingly… here it is in case its necessary:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>SSC01</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.muzoo.ssc</groupId>
<artifactId>assignment-tracker</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.6.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>m2.ssc.muzoo.io</id>
<url>https://m2.ssc.muzoo.io</url>
</repository>
</repositories>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<mainClass>org.example.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>