0

I have a jar file named- ParseCSV-0.0.1-SNAPSHOT.jar and the contents of it are -

  • META-INF/
  • META-INF/MANIFEST.MF
  • foo/
  • foo/ReadCSV.class
  • META-INF/maven/
  • META-INF/maven/Test/
  • META-INF/maven/Test/ParseCSV/
  • META-INF/maven/Test/ParseCSV/pom.xml
  • META-INF/maven/Test/ParseCSV/pom.properties

The main class is ReadCSV.class and it takes a CSV file (C:\Testting\ValidaResults.csv) as an input parameter. I am trying to execute the jar file from the command promt by running the following command-

java -jar . ParseCSV-0.0.1-SNAPSHOT.jar "C:\Testting\ValidationResult.csv"

But I am getting an error saying-

Error: Could not find or load main class foo.ReadCSVTest

What is going wrong here.

maxx777
  • 1,320
  • 1
  • 20
  • 37
Som Sarkar
  • 289
  • 1
  • 5
  • 24

2 Answers2

1

Why do you have a . between jar and ParseCSV..?

Try this first:

java -jar ParseCSV-0.0.1-SNAPSHOT.jar "C:\Testting\ValidationResult.csv"

If this does not work, then try:

java -cp ParseCSV-0.0.1-SNAPSHOT.jar;. foo.ReadCSV "c:\Testting\ValidationResult.csv" 

If this works, then i would inspect the META-INF/MANIFEST.MF file to figure out what the classpath is like, and what the value of Main-Class is. It seems to be running ReadCSVTest instead of ReadCSV.

user2533521
  • 236
  • 1
  • 4
0

Your JAR file includes foo/ReadCSV.class, but your MainClass is set to foo.ReadCSVTest. You'll need to fix your Main-Class attribute in META-INF/MAINIFEST.MF

Bill Brasky
  • 2,614
  • 2
  • 19
  • 20