简体   繁体   English

执行jar文件时出错

[英]Error in executing a jar file

I have a jar file named- ParseCSV-0.0.1-SNAPSHOT.jar and the contents of it are - 我有一个名为-ParseCSV-0.0.1-SNAPSHOT.jar的jar文件,其内容是-

  • META-INF/ META-INF /
  • META-INF/MANIFEST.MF META-INF / MANIFEST.MF
  • foo/ 富/
  • foo/ReadCSV.class 富/ ReadCSV.class
  • META-INF/maven/ META-INF / maven的/
  • META-INF/maven/Test/ META-INF /行家/测试/
  • META-INF/maven/Test/ParseCSV/ META-INF /行家/测试/ ParseCSV /
  • META-INF/maven/Test/ParseCSV/pom.xml META-INF /行家/测试/ ParseCSV / pom.xml的
  • META-INF/maven/Test/ParseCSV/pom.properties META-INF /行家/测试/ ParseCSV / pom.properties

The main class is ReadCSV.class and it takes a CSV file (C:\\Testting\\ValidaResults.csv) as an input parameter. 主要类是ReadCSV.class,它采用CSV文件(C:\\ Testting \\ ValidaResults.csv)作为输入参数。 I am trying to execute the jar file from the command promt by running the following command- 我正在尝试通过运行以下命令从命令promt执行jar文件-

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. 这里出了什么问题。

Why do you have a . 为什么你有一个 。 between jar and ParseCSV..? 在jar和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. 如果这可行,那么我将检查META-INF / MANIFEST.MF文件以找出类路径是什么,以及Main-Class的值是什么。 It seems to be running ReadCSVTest instead of ReadCSV. 它似乎正在运行ReadCSVTest而不是ReadCSV。

Your JAR file includes foo/ReadCSV.class, but your MainClass is set to foo.ReadCSV Test . 您的JAR文件包含foo / ReadCSV.class,但是您的MainClass设置为foo.ReadCSV Test You'll need to fix your Main-Class attribute in META-INF/MAINIFEST.MF 您需要在META-INF / MAINIFEST.MF中修复Main-Class属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM