Win服务器上的Java,bat运行包

时间:2022-03-09 02:08:41

To begin with, I dont know much Java, but we have some old Java applications on my firm that collects information that runs every night, however recently it stopped working. There is a bat file that, from what I understand, runs all the required packages, however, when I run it, it returns "Could not find or load main class -insert whatever class I put second - "

首先,我不太了解Java,但我们公司有一些旧的Java应用程序,它们收集每晚运行的信息,但最近它停止工作。根据我的理解,有一个bat文件运行所有必需的包,但是,当我运行它时,它返回“无法找到或加载主类 - 插入我放入的第二个类 - ”

Code from the .bat file:

.bat文件中的代码:

java -cp com.spprod.mywysiwyg.NY.jar; mysql-connector-java-3.1.10-bin.jar; com.spprod.mywysiwyg.CalculateDailyStats;

The first one is the whole package, and the second one is the connector, they are both in the same folder, but in the cmd I get the error that it cant find mysql. If I switch order with 2nd and 3rd it says that I cant find "CalculateDailyStats" instead. Is there something wrong with this line of code?

第一个是整个包,第二个是连接器,它们都在同一个文件夹中,但在cmd中我得到的错误是它无法找到mysql。如果我用第二和第三顺序切换顺序,它说我找不到“CalculateDailyStats”。这行代码有什么问题吗?

Thanks in advance.

提前致谢。

1 个解决方案

#1


2  

The -cp switch specifies the classpath in java (path where to look for the files). The jars after -cp are separated with semicolon.

-cp开关指定java中的类路径(查找文件的路径)。在-cp之后的罐子用分号分隔。

Now, I suppose, that you are trying to run com.spprod.mywysiwyg.CalculateDailyStats class. So, maybe the last semicolons are confusing e.g. try the following:

现在,我想,您正在尝试运行com.spprod.mywysiwyg.CalculateDailyStats类。所以,也许最后的分号令人困惑,例如尝试以下方法:

java -cp com.spprod.mywysiwyg.NY.jar;mysql-connector-java-3.1.10-bin.jar com.spprod.mywysiwyg.CalculateDailyStats

#1


2  

The -cp switch specifies the classpath in java (path where to look for the files). The jars after -cp are separated with semicolon.

-cp开关指定java中的类路径(查找文件的路径)。在-cp之后的罐子用分号分隔。

Now, I suppose, that you are trying to run com.spprod.mywysiwyg.CalculateDailyStats class. So, maybe the last semicolons are confusing e.g. try the following:

现在,我想,您正在尝试运行com.spprod.mywysiwyg.CalculateDailyStats类。所以,也许最后的分号令人困惑,例如尝试以下方法:

java -cp com.spprod.mywysiwyg.NY.jar;mysql-connector-java-3.1.10-bin.jar com.spprod.mywysiwyg.CalculateDailyStats