在Xcode 4中编译Java

在Xcode 4中编译Java,java,xcode,macos,compiler-construction,Java,Xcode,Macos,Compiler Construction,我知道这个问题已经浮出水面很久了 Xcode 4中的Java 我不需要任何建议(例如Eclipse、Netbeans),我只想在“XCode4”(而不是3)中编译一些简单的Java代码。我设法创建了一个文件,正如预期的那样,语法和所有东西都正常工作,但由于缺少方案,编译器除外。我被可执行文件卡住了 我的问题是: 有可能吗 有可能吗 是的,这是可能的。 1) File > New > New Project > Other > External Build System 2) Give i

我知道这个问题已经浮出水面很久了

Xcode 4中的Java

我不需要任何建议(例如Eclipse、Netbeans),我只想在“XCode4”(而不是3)中编译一些简单的Java代码。我设法创建了一个文件,正如预期的那样,语法和所有东西都正常工作,但由于缺少方案,编译器除外。我被可执行文件卡住了

我的问题是:

有可能吗

有可能吗

是的,这是可能的。

1) File > New > New Project > Other > External Build System 2) Give it some name and save it somewhere. 3) File > New > New File > Other > Empty 4) Give it a Java-friendly name. In my example, use "HelloWorld.java" 5) Copy the contents below into the file and save. 6) File > New > New File > Other > Empty 7) Save as "Makefile". 8) Copy the contents below into the file and save. 9) The "Run" (>) button should at least compile your Java now. 1) 文件>新建>新建项目>其他>外部生成系统 2) 给它起个名字,把它保存在某个地方。 3) 文件>新建>新建文件>其他>空 4) 给它一个Java友好的名称。在我的示例中,使用“HelloWorld.java” 5) 将以下内容复制到文件中并保存。 6) 文件>新建>新建文件>其他>空 7) 另存为“Makefile”。 8) 将以下内容复制到文件中并保存。 9) “Run”(>)按钮至少应该现在就编译Java。 现在情况变得棘手了。你不必做下一部分。如果需要,您可以打开项目目录的终端并运行“java HelloWorld”。我强烈建议。您也可以只键入“make”并将Xcode纯粹用作文本编辑器

9) Project > Edit Scheme > Debug > Info 10) Executable > Other > type ^⌘g > type "/bin" > choose "sh" 11) Arguments 12) Set "Base Expansion on" whatever you named your target 13) Add an argument '-c "/usr/bin/java -classpath $(PROJECT_DIR) HelloWorld"' for this example. 14) Cross your fingers 15) Click the "Run" (>) button. 9) 项目>编辑方案>调试>信息 10) 可执行文件>其他>类型^⌘g>类型“/bin”>选择“sh” 11) 论据 12) 将“基础扩展”设置为您命名的目标 13) 为本例添加一个参数“-c”/usr/bin/java-classpath$(PROJECT_DIR)HelloWorld“”。 14) 祝你好运 15) 单击“运行”(>)按钮。 摘自