使用 Eclipse 打开命令提示符

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

Open command prompt using Eclipse

javaeclipse

提问by user21968

I am new to Java and am trying to run a program using Eclipse. But I have no idea how to get the command prompt running in with Eclipse...

我是 Java 新手,正在尝试使用 Eclipse 运行程序。但我不知道如何在 Eclipse 中运行命令提示符......

I did some online research and couldn't get anything consolidated!

我做了一些在线研究,但无法整合任何东西!

Update:

更新:

I'm not using an applet. It's a normal Java program trying to read a line from command prompt. I'm trying to do system programming.

我没有使用小程序。这是一个普通的 Java 程序,试图从命令提示符中读取一行。我正在尝试进行系统编程。

回答by KC Baltz

Check out this lesson plan on how to get started with Eclipse programs:

查看有关如何开始使用 Eclipse 程序的课程计划:

Lesson

Specifically, see this image:

具体看这张图:

Picture of Eclipse Console with Standard Input

带有标准输入的 Eclipse 控制台图片

If the Console tab is not visible in your Eclipse, go to Window -> Show View -> Console in the menu bar.

如果控制台选项卡在 Eclipse 中不可见,请转到菜单栏中的窗口 -> 显示视图 -> 控制台。

回答by Rayne

If you downloaded the Eclipse/Java package, and you wrote a Java program in Eclipse in a project, just click compile and run, it will run in the output window in Eclipse.

如果你下载了Eclipse/Java包,在一个项目中用Eclipse编写了一个Java程序,只要点击编译运行,它就会在Eclipse的输出窗口中运行。

回答by Pablo Fernandez

Try this:


import java.util.Scanner;

    public class ReadFromPrompt{

       public static void main(String[] args) {

           Scanner in = new Scanner(System.in);

           String line = in.nextLine();     

        }
    }

回答by Karthik Reddy

Right Click on your project--->Run As--->Run Configurations...--->Select Arguments-->Enter the values---->Run