Eclipse - 编译&执行程序 [英] Eclipse - Compiling & executing program
问题描述
过去,我使用JCreator开发我的java应用程序。我想试试Eclipse并看看它的IDE。
在JCreator上,我可以打开一个java文件并在命令提示符下运行它。在Eclipse上,我无法找到如何编译和运行由别人编写的java文件,而无需先创建一个项目,创建一个新的java类,然后从文件中复制和粘贴代码。
我甚至不知道如何将java文件导入到项目中。
所以我的问题:
1.如何在不首先创建java项目的情况下打开,编译和运行java文件。
2.如何将java文件导入到我已经有的项目中。
3.如何在命令提示符下运行程序,而不是在Eclipse中的控制台上运行程序(update :更清楚)直接从Eclipse。
谢谢。
1 / href =http://www.eclipsezone.com/eclipse/forums/t61137.html =nofollow noreferrer> 剪贴簿页 (也)
3 /由于你希望它直接从eclipse运行, =http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg13643.html =nofollow noreferrer>在此主题中指出,外部工具
外部工具将运行 C:\WINDOWS\system32\cmd.exe
code> $ {container_loc}
这将会:
In the past, I have used JCreator to develop my java applications. I wanted to try Eclipse and see its IDE.
On JCreator, I could just open a java file and run it in the command prompt. On Eclipse, I cannot find out how I can compile and run a java file written by someone else without first creating a project, creating a new java class and then copy and pasting the code from the file.
I cannot even figure out how to import a java file into the project.
So my questions:
1. How can I open, compile and run a java file without first creating a java project.
2. How can I import a java file into a project I already have.
3. How can I run the program in command prompt, instead of on the console that is in Eclipse, (update: to be more clear) directly from the Eclipse.
Thank you.
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 ?".
That will give:
这篇关于Eclipse - 编译&执行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!