如何使用 Eclipse 运行 Java 我的项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9841505/
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-08-16 08:26:41  来源:igfitidea点击:

How to run Java my project with eclipse

java

提问by user1269592

I have started learning Java and I have 1 issue:

我已经开始学习 Java,但有 1 个问题:

I write a simple class and it runs and everything's fine. I took all the project from my Laptop to my other computer and from Eclipse I choose "File --> Open File" and choose my .java file.

我写了一个简单的类,它运行起来,一切都很好。我将所有项目从我的笔记本电脑带到了我的另一台计算机,然后从 Eclipse 中选择“文件 --> 打开文件”并选择我的 .java 文件。

When I try to run my program this windows pop up:

当我尝试运行我的程序时,会弹出以下窗口:

enter image description here

在此处输入图片说明

and after trying both option nothing happen.

在尝试了这两个选项之后,什么也没有发生。

How can I run my program and what is the problem ?

我怎样才能运行我的程序,有什么问题?

采纳答案by GingerHead

Perform the following steps:

执行以下步骤:

  1. Create a new project in eclipse
  2. Link your classes from the project properties' buildpath
  3. Go to Run->Run Configurations
  4. Create a new configration
  5. Point your mainclass
  6. And Run
  1. eclipse中新建一个项目
  2. 从项目属性的构建路径链接您的类
  3. 转到运行->运行配置
  4. 创建新配置
  5. 指向你的
  6. 并运行

回答by hndr

if you are just starting learning Java and dont understand whats going on with all that stuff with eclipse, I would recommend you to start from the basics, write your code in an ordinary text editor (notepad will do, or notepad++ if you want something more), after you have written and saved your source file, open up your command prompt, navigate to the location of the file, and run:

如果您刚开始学习 Java 并且不了解 Eclipse 的所有内容,我建议您从基础开始,在普通文本编辑器中编写代码(记事本可以,或者记事本++,如果您想要更多的话) ),在编写并保存源文件后,打开命令提示符,导航到文件所在的位置,然后运行:

javac YourFileName.java
java YourFileName

here is more detailed guide:http://introcs.cs.princeton.edu/java/15inout/windows-cmd.html

这里是更详细的指南:http://introcs.cs.princeton.edu/java/15inout/windows-cmd.html

回答by aretai

There is no problem with learning Java with Eclipse or any other IDE. If you move file from one computer to the other you need as it was said start a new project or you can use existing project and import files. In order to import files right click on a project and click then Import and select files. Then you should be able to run your class. Also be sure to have the Java perspective selected when you work on your class.

使用 Eclipse 或任何其他 IDE 学习 Java 没有问题。如果您将文件从一台计算机移动到另一台计算机,则需要启动一个新项目,或者您可以使用现有项目并导入文件。为了导入文件,右键单击一个项目,然后单击“导入”并选择文件。然后你应该能够运行你的类。还请确保在您处理类时选择 Java 透视图。

回答by MainstreamOP

you need to create your public class and then just click on the green button with the white triangle on it ;) See here: http://i.stack.imgur.com/5TEtI.png

您需要创建您的公共课程,然后只需单击带有白色三角形的绿色按钮;) 请参阅此处:http: //i.stack.imgur.com/5TEtI.png