简体   繁体   中英

Shell Command to run a main class from jar

I am running a shell command to run a main class from a jar. I am using the following command-

java -cp ./knowledge-generator.jar com.abc.rdf.file.FileGenerator    --inputFiles `pwd`/abc.ttl --outputFolder `pwd`

But everythime I am getting the error-

Error: Could not find or load main class com.abc.rdf.file.FileGenerator

I checked the solution given here but that did not help me. What is going wrong here.

使用以下命令run jar-

java -jar ./knowledge-generator.jar

Add the full path of the jar that you're adding to your classpath. For example:

java -cp C:/myprog/knowledge-generator.jar com.abc.credit.data.knowledgegenerator.KnowledgeGenerator --inputFiles `pwd`/CIA_CP_LDM.ttl --outputFolder `pwd`

The error you are getting means that the class you are specifiying is not found on the classpath.

This could be eiether because you have mispelled the class name or the class itself or the jar file containing it is not on the classpath.

Since you are usging ./knowledge-generator.jar this means that the jar file is located on the same directory from where you are executing the command (current wurking directory). make sure the jar file is there (execute the command ls) and that the jar file contains the class you are trying to use as entry point to your java application

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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