在Xcode 4中编译Java [英] Compile Java in Xcode 4

查看:324
本文介绍了在Xcode 4中编译Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经存在了很长时间......

I know that this question has been floating around for ages now ...

Xcode 4中的Java

我不需要任何建议(例如Eclipse,Netbeans)我只想在XCode4(而不是3)中编译一些简单的Java代码。我设法创建一个文件,正如预期的那样语法和一切正常但由于缺少Scheme而编译器。我有点卡在可执行文件上。

I don't need any recommendations (Eclipse, Netbeans e.g.) I just want to compile some simple Java Code in "XCode4" (not 3). I managed to create a File and as expected the syntax and everything works but the Compiler due to the missing Scheme. I am kinda stuck at the executable.

我的问题是:

是否可以这样做?

推荐答案


是否可以这样做?

Is it possible to do that?

是的,这是可能的。


    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.

现在变得棘手了。你不必做下一部分。您可以打开一个终端到您的项目目录并运行java HelloWorld,如果您愿意。我强烈建议。您也可以只输入make并将Xcode纯粹用作文本编辑器。

Now it gets tricky. You don't have to do the next part. You could just open a Terminal to your project directory and run "java HelloWorld" if you want. I strongly suggest that. You can also just type "make" and use Xcode purely as a text editor.


    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.

摘自 Apple支持社区

这篇关于在Xcode 4中编译Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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