2013-04-11 17 views
12

私はこの質問は、今の年齢のために漂ってきたことを知っているで... コンパイルJavaのXcodeの4

のJava

Xcodeの4インチ

推奨事項はありません(Eclipse、Netbeansなど) "XCode4"(3ではない)で単純なJavaコードをコンパイルしたいだけです。私はFileを作成することができました。期待どおりの構文とすべてが機能しますが、Schemeがないためにコンパイラが機能します。私は実行可能ファイルにある程度固執しています。

私の質問は:

これは可能ですか?

答えて

17

これは可能ですか?

はい可能です。

 
    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. 

これで手間がかかります。あなたは次の部分をする必要はありません。必要に応じて、プロジェクトディレクトリにTerminalを開き、 "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. 

Apple Support Community

から抜粋