简体   繁体   English

Netbeans项目的两个主要课程

[英]Two main classes on netbeans project

So I'm working on a large project and I want to implement a function to send emails automatically with reports at let's say 12:00 am. 所以我正在做一个大型项目,我想实现一个功能,比如说上午12:00自动发送带有报告的电子邮件。 I have successfully created the aforementioned routine, which reads a file with a list of mails and sends them (I have the mails saved under my root directory, because other part of my program allows users to edit the list of mails themselves), as I need to send the mails at 12:00 am regardless my application is running or not, I created a main() in order to schedule the routine in my Windows OS. 我已经成功创建了上述例程,该例程读取包含邮件列表的文件并将其发送(我将邮件保存在根目录下,因为程序的其他部分允许用户自己编辑邮件列表),就像我一样无论我的应用程序是否运行,都需要在凌晨12:00发送邮件,因此我创建了main()以便在Windows OS中安排例程。

My question is, how can I run this routine (which uses the main application classes to generate the report) when I already have another main() in the same project (which is the user interface) and not creating conflicts? 我的问题是,当我在同一项目(用户界面)中已有另一个main()并且不产生冲突时,如何运行该例程(使用主应用程序类来生成报告)? If I run the project as a whole on netbeans it runs my gui as expected, same from command prompt, but I can't run my mail routine from the console (on netbeans it runs fine with Run File...) 如果我在netbeans上整体运行该项目,则它会按预期方式运行我的GUI,与命令提示符相同,但是我无法从控制台运行我的邮件例程(在netbeans上,它可以与Run File一起正常运行...)

为了告诉java要运行哪个Main-Method,可以使用以下语法:

java -cp YourJar.jar com.package.to.your.YourMainClass

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

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