Java - 如何使用 Java Eclipse 编译单个文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15349182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 19:19:09  来源:igfitidea点击:

Java - How to Compile a single file with Java Eclipse

javacompilationconsole

提问by madhu131313

I am trying to compile one file in a java project, but I am seeing other result (result of another file ) in console. I even tried Ctrl+ F11but the same thing happened

我正在尝试在 java 项目中编译一个文件,但我在控制台中看到了其他结果(另一个文件的结果)。我什至尝试过Ctrl+F11但同样的事情发生了

In the dropdown of Run button of Java I am not finding the current file name but if I start a new project and run the file it is compiling. Note:I am a beginner in Java.

在 Java 的运行按钮的下拉菜单中,我没有找到当前文件名,但是如果我启动一个新项目并运行它正在编译的文件。注意:我是 Java 的初学者。

采纳答案by Axel

Your class has to define a public static void main(String[] args)method. Then find the Java file in the project explorer, right-click on it, and choose "run as Java application".

你的类必须定义一个public static void main(String[] args)方法。然后在项目资源管理器中找到 Java 文件,右键单击它,然后选择“作为 Java 应用程序运行”。

回答by Java42

In addition to the info in the answer already selected, others having this or a similar problem should chech the "Run Configurations" panel to make sure the setting are correct for the app you are launching. Check

除了已选择的答案中的信息外,其他遇到此问题或类似问题的人应检查“运行配置”面板,以确保您启动的应用程序的设置正确。查看

Run Configurations

运行配置

Run Configurations

运行配置