在 Xcode 中编写 Java 程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11775813/
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
Writing a Java program in Xcode
提问by ConorW
I am trying to begin writing a Java program in Xcode 4.4
but, At the moment, I am stuck with the file extension .cpp
, which I believe is for C++. Can some please tell me how to set up a .java
file (or project, or whatever the term is)...? I am extremely new to programming, and to Xcode, so please keep all instructions /very/ simple.
我正在尝试开始编写 Java 程序,Xcode 4.4
但是目前,我坚持使用文件扩展名.cpp
,我认为它适用于 C++。有人可以告诉我如何设置.java
文件(或项目,或任何术语)...?我对编程和 Xcode 非常陌生,所以请保持所有说明/非常/简单。
回答by javacom
I have created some Xcode Templates for Xcode 4 here http://www.2shared.com/file/hExLjJ1X/Java_Xcode4_template2.html
我在这里为 Xcode 4 创建了一些 Xcode 模板 http://www.2shared.com/file/hExLjJ1X/Java_Xcode4_template2.html
To install the template in Mac, use Terminal command
要在 Mac 中安装模板,请使用终端命令
mkdir -p ~/Library/Developer/Xcode/Templates/
unzip ~/Downloads/Java_Xcode4_template2.zip -d ~/Library/Developer/Xcode/Templates/
You can use command-B to build. To Run, you should use "Edit Scheme..." and change the Executable for the "Run" Scheme
您可以使用 command-B 来构建。要运行,您应该使用“编辑方案...”并更改“运行”方案的可执行文件
回答by Juan González
If you're new to programming you might want to try this in a different way.
如果您是编程新手,您可能想以不同的方式尝试这个。
Better IDEs for Java are Netbeans and Eclipse. I've used Netbeans for Java and PHP as well. It behaves as you could expect from a modern IDE with a lot of possibilities for customizing it to your needs/preferences.
更好的 Java IDE 是 Netbeans 和 Eclipse。我也将 Netbeans 用于 Java 和 PHP。它的行为正如您对现代 IDE 所期望的那样,有很多可能性可以根据您的需求/偏好对其进行自定义。
Xcode is great and has many useful tools but it's focused on objective-c and iOS environment.
Xcode 很棒,有很多有用的工具,但它专注于 Objective-c 和 iOS 环境。
Good luck!
祝你好运!
回答by matematika
I am using XCode currently.
我目前正在使用 XCode。
Open a new project.
Click External Build System.
- Name your file, using the extension .java.
- Write $(TARGETNAME).java next to $(ACTION).
- Open a new file (empty style).
- Start writing your program.
打开一个新项目。
单击外部构建系统。
- 使用扩展名 .java 命名您的文件。
- 在 $(ACTION) 旁边写上 $(TARGETNAME).java。
- 打开一个新文件(空样式)。
- 开始编写程序。
XCode is not the best place for Java, but I use it since it is a developer tool for Apple and it has great syntax coloring and auto-indentation, etc.
XCode 不是 Java 的最佳位置,但我使用它是因为它是 Apple 的开发人员工具,并且具有出色的语法着色和自动缩进等。
TextEdit is another app (probably already there if you use Apple Mac), but no syntax coloring and fancy features. It is simpler to use, and always use Terminal (try to avoid using the XCode Build - the errors are hard to decipher and the process is complicated, also if you have any questions, few can answer it because most do not use XCode).
TextEdit 是另一个应用程序(如果您使用 Apple Mac,可能已经存在),但没有语法着色和花哨的功能。它使用起来更简单,并且总是使用终端(尽量避免使用 XCode Build - 错误难以破译,过程复杂,如果你有任何问题,很少有人能回答,因为大多数人不使用 XCode)。
Good luck!
祝你好运!