I have a java program that I coded in intellij using maven. I exported it as a jar and tried running from the command line but it keeps on telling me
Error: Could not find or load main class com.company.Main Caused by: java.lang.ClassNotFoundException: com.company.Main
I then attempted to run the program itself from the command line and that also tells me it cannot find the main class
command line: for the jar: java -jar selenium_project.jar
for running the program :java com.company.Main
For the jar I am running it from the folder it is in. For the program I am running it from the root of the program.
Pom.xml
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <index>true</index> <manifest> <mainClass>com.company.Main</mainClass> </manifest> </archive> </configuration> </plugin> </plugins></build> Manifest:
Manifest-Version: 1.0 Main-Class: com.company.Main It might be an issue with maven, I dont know. I created a simple hello world program and ran that from the command line and it worked. I ran it like this (c://etc)../src/> java com.company.HelloWorld. But again when i try for this one it cannot find the main class. Thank you
https://stackoverflow.com/questions/65525805/running-java-program-jar-from-command-line January 01, 2021 at 05:52AM
没有评论:
发表评论