Eclipse - 编译&执行程序 [英] Eclipse - Compiling & executing program
问题描述
在过去,我已经使用JCreator来开发我的java应用程序。我想尝试Eclipse并看到它的IDE。
在JCreator上,我可以打开一个java文件并在命令提示符下运行它。在Eclipse中,我无法找到如何编译和运行别人写的java文件,而无需先创建一个项目,创建一个新的java类,然后从文件中复制和粘贴代码。
我甚至无法弄清楚如何将java文件导入到项目中。
所以我的问题:
1.如何在没有首先创建java项目的情况下打开,编译和运行java文件。
2.如何将java文件导入到我已经拥有的项目中。
3.如何在命令提示符下运行程序,而不是在Eclipse中的控制台上(更新:更清楚)直接从Eclipse。
谢谢。
1 /不要忘记)
3 /由于您希望直接从eclipse运行,请使用为在此线程中指出,外部工具
该外部工具将运行 C:\WINDOWS\system32\cmd.exe
与工作目录 $ {container_loc}
这篇文章如何在我的控制台中打开Windows命令提示符? 。
这将给出:
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屋!