Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用日食。我在同一个项目中有两个单独的包。在每个包中,都有一个具有主函数的类。但是,当我运行 package2 中的类时,我发现 package1 中的类的 main 函数被执行了。我该如何解决这个问题?
导航到运行/调试启动配置对话框,并将选项卡Main class上的字段设置为Main包含所需主方法的类。
如果您在 Eclipse 中,请右键单击类并选择“运行/作为 java 应用程序”。它会正确运行main()。
main()
right click the project -> run as-> run configuration.
在那里你会找到一个指定主类的选项。选择要调用的主类,然后按运行。