張貼日期:2014/12/26 下午 07:15:01
我的小筆記,僅提供參考,給同情況、跟我同方法可以解決的人
理論方面編譯器那些我不是很懂,可能問我問題,我也不知道
只懂用基礎語法寫小程式
我不知道為什麼新版xcode為什麼沒有Java,在有的之前,我也沒用xcode寫過java
before my note, i never code java on xcode, and i don't know why xcode new version no java default template env there
my little notes, i hope helpful to you
Java Development on Xcode
1) New Project > Other > External Build System
2) Named <ProjectName>
3) File > New > New File > Other > Empty
4) Give it a Java-friendly name. In my example, use xxx.java
5) Copy the contents below into the file and save
xxx.java:
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
6) Project setting
Target setting
Build Tool:/usr/bin/javac
Arguments:$(ACTION) $(TARGETNAME).java
Notice:target name have same as xxx.java
這邊是讓java檔可以編譯成class檔,所以你跑完build會產生xxx.class
6.1) Project > Scheme > Edit Scheme > RUN Setting(left side)
Edit Schemes:
info tab
Executable > Other > type ^⌘g > type /usr/bin/java > choose java
Debug executable checked cancel
這邊是讓debug不要用原本的庫去檢查你的java程式
不然會得到dyld 例外
arguments tab
For Arguments Passed on Launch, add $(TARGETNAME)
For Environment Variables, add CLASSPATH with a value of $(PROJECT_DIR)
options tab
Working Directory (check this)
Choose your project dir location
6.2) Project > Scheme > Edit Scheme > Test Setting(left side)
info tab
Debugger LLDB to None
(if Debug executable checked cancel, you can forget step 6.2 )
這邊是讓debug不要用原本的庫去檢查你的java程式
不然會得到dyld 例外
好像不用調也可以,只要Debug executable取消
Extensions Library:
jar put in
/Library/Java/Extensions
ref.
Xcode and the Simple C++ Project Structure - The Hiltmon
Developing Java in Xcode | Apple Support Communities
YouTube - Java Development on Mac (Xcode) [Tutorial]
YouTube - Java + Xcode [No Terminal] [Tutorial]
另外觀念可參考