Sitemap

Compile Java In Xcode

2 min readFeb 20, 2016

--

Recently I start to read Algorithm 4th which uses Java to express the thought of algorithm. However , I had not even write a helloworld.java file until I opened this book.

I found some steps to compile java in Xcode and I make of note of these steps.

  1. Install java and make sure there are bin files named java and javac in your /usr/bin/ ;
  2. Open Xcode ;
  3. New project — Other — External Build System;
  4. Set the build tool to /usr/bin/javac;
public class helloWorld
{
public static void main(String[] args)
{
System.out.println("hello world");
}
}

5. Clicking the “Run >” button should at least compile your file now, but it is not really running . However , you can find a compiled file named <JavaFileName>.class in the same place if things go right;

Get Jsonzhang’s stories in your inbox

Join Medium for free to get updates from this writer.

6. And then we focus on the menu and select Product — Scheme — Edit Scheme , select Executable — other… and use command+shift+G to located the /usr/bin/java ,at the same time you should uncheck the Debug Executable if you don’t need that;

Press enter or click to view image in full size
Press enter or click to view image in full size

7. Select Argument tab and add argument and variable as follow(You can add common arguments which you like to pass on launch);

Press enter or click to view image in full size

8. Now you can enjoy the automatic compiling and running Java program code with Xcode by simple hitting command + R.

Watch the tutorial in video version :

--

--

Jsonzhang
Jsonzhang

Written by Jsonzhang

如今常存的有信,有望,有爱,这三样,其中最大的是爱 。-- 歌林多前書 13:13