简体   繁体   English

错误:从Linux命令行运行时找不到或加载主类Main-

[英]Error: Could not find or load main class Main - when running from Linux command line

Originally, I was able to run my code from command line as such: 最初,我可以这样从命令行运行代码:

java -cp "/var/www/html/tcqa/bin/test_and_control-1.0-SNAPSHOT.jar:/var/www/html/tcqa/bin/postgresql-9.3-1100-jdbc41.jar" Main /var/www/html/tcqa/sql/tc.sql

I needed to add some new functionality and decided to break out the main class and use case to manage which sql statement would get run. 我需要添加一些新功能,并决定突破主类和用例来管理将运行的sql语句。 I moved my main class out and have not been able to get my code to run from command line. 我将主类移出,无法从命令行运行我的代码。 My new command line looks like this: 我的新命令行如下所示:

java -cp ["/home2/smontoya/test_and_control-1.0-SNAPSHOT.jar:/var/www/html/tcqa/bin/postgresql-9.3-1100-jdbc41.jar;"] Main email /var/www/html/tcqa/sql/email.sql

Obviously I want to test this before moving it into production mode. 显然,我想在将其移入生产模式之前对其进行测试。 My code structure looks like this: 我的代码结构如下所示:

main
|-->java
    |--> email
    |    |__ EmailFlag
    |    |__ EmailRow
    |--> tc
    |    |__  Analytics
    |    |__ Row
    |    |__  TestAndControl
    |    |__  Utils
    |--> Main

Please check your manifest file in the jar.. It describes the version and mainClass. 请检查jar中的清单文件。它描述了版本和mainClass。 If you are using maven .. While adding dependencies to build jar describe the main class in configuration so that maven will add this configuration to manifest file 如果您正在使用maven ..在添加依赖项以构建jar时,请描述配置中的主类,以便maven将此配置添加到清单文件中

尝试指定Main的标准名称:

java -cp /path1:/path2 com.company.Main arg1 arg2

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

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