2013-04-11 13 views
12

So che questo problema è stato galleggianti intorno per le età ora ...Compile Java in Xcode 4

Java in Xcode 4.

Non ho bisogno di alcun consiglio (Eclipse, Netbeans, ad es.) Voglio solo compilare qualche semplice codice Java in "XCode4" (non 3). Sono riuscito a creare un file e come previsto la sintassi e tutto funziona, ma il compilatore a causa della Schema mancante. Sono abbastanza bloccato nell'eseguibile.

mia domanda è:

E 'possibile farlo?

risposta

17

È possibile farlo?

Sì, questo è possibile.

 
    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. 

Ora diventa complicato. Non devi fare la parte successiva. Potresti semplicemente aprire un terminale nella directory del tuo progetto ed eseguire "java HelloWorld" se lo desideri. Lo suggerisco fortemente. Puoi anche solo digitare "make" e usare Xcode puramente come editor di testo.

 
    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. 

un estratto dalApple Support Community