Eclipse-编译和执行程序 [英] Eclipse - Compiling & executing program

查看:69
本文介绍了Eclipse-编译和执行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,我曾使用JCreator开发我的Java应用程序.我想尝试Eclipse并查看其IDE.

在JCreator上,我可以打开一个Java文件并在命令提示符下运行它.在Eclipse上,如果不先创建项目,创建新的Java类,然后从文件中复制并粘贴代码,就无法找到如何编译和运行别人编写的Java文件的方法.

我什至不知道如何将Java文件导入项目.

所以我的问题:
1.如何在不首先创建Java项目的情况下打开,编译和运行Java文件.
2.如何将Java文件导入到已有的项目中.
3.如何直接在Eclipse中而不是在Eclipse的控制台上在命令提示符下运行程序(更新:更加清楚).

谢谢.

解决方案

1/不要忘记)

3/由于您希望它直接从eclipse运行,因此请用作
(来源:
(来源: 解决方案

1/ Do not forget scrapbook page (also presented here)

In theory, you could copy a class in it, but since that class is actually encapsulated into a "main invisible" class, as an inner class, it would not support any static methods in it.

However, for a quick chunk of code, it does the trick just fine.


(from this Eclipse tutorial)

3/ Since you want it run directly from eclipse, use as indicated in this thread, an External tool

That External Tool would run C:\WINDOWS\system32\cmd.exe with working directory ${container_loc}

More details in this article "How do I open a Windows Command Prompt in my console ?".


(source: avajava.com)

That will give:


(source: avajava.com)

这篇关于Eclipse-编译和执行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆