Saturday, September 15, 2012

How to create java project in XCode 4

(1) Download the required file here and unzip it after download. http://www.2shared.com/file/vt3Flvvs/hellojava.html

Please choose the bottom blue download button in the download page.



(2) Create a new project in XCode 4, Choose "Other" -> "External Build System"


(3) Enter the Product Name say "project1".  For Build Tool enter /usr/bin/ant


(4) Save the project in your disk

(5) Right click your "project1" in XCode 4 and Choose "Add Files to project1"


(6) Choose the file (build.xml) and folders (lib, resources, resources_macosx and src) in the unzipped file downloaded in step 1
Select "Copy items into destination group's folder (if needed)" and "Create groups for any added folders" and Press "Add" button.

(7) Edit build.xml and change the Project name attribute from "hellojava" to your Product Name say "project1"


(8) Edit Manifest and change the Main-Class from "hellojava" to your Product Name say "project1"


(9) Edit the filename hellojava.icns to Product Name say "project1.icns"


(10) Edit the filename hellojava.java to Product Name say "project1.java"


(11) Edit the class name in "project1.java" and change from "hellojava" to your Product Name say "project1" and then press "Command S" to save


(12) Press "Command B" to build


(13) Right click your "project1" in XCode 4 and Choose "Add Files to project1" again


(14) Choose folders (bin, dist and jars) from your save project location.
Select "Copy items into destination group's folder (if needed)" and "Create folder references for any added folders" and Press "Add" button.


(15) Select "Product" -> "Edit Scheme..." menu


(16) Select the "Run" Scheme and change the Executable "None"


(17) And Choose the "project1" app under the "dist" folder of the saved project location.


(18) Repeat the steps 16 and 17 but for the "Profile" Scheme.

(19) Press "Command R" to run. And a simple Hello World app is created with java source code.


(20) Modify the source code in "project1.java" to proceed further.



Here is the Xcode 4 Template for Java (v2)
http://www.2shared.com/file/hExLjJ1X/Java_Xcode4_template2.html

To install the template in Mac, use Terminal command
mkdir -p ~/Library/Developer/Xcode/Templates/
unzip ~/Downloads/Java_Xcode4_template2.zip -d ~/Library/Developer/Xcode/Templates/


To Run after build (Command R), you have to do steps 15 to 18 above.

6 comments:

Unknown said...

Its a good project but do not for the beginners as it is not so easy..
hard drive recovery dallas

Ruedi Heimlicher said...

Very good project, but:
Building leaves me with an error:
***commands commence before first target. Stop
on line 17 of the build.xml file.
What is going wrong?

And another question:
I had to give rwx rights to the product file to be able to choose it as an executable. Is that right?
Thanks
Ruedi

Djamé said...

Hi,
the download links of your templates don't seem to work. Do you still have them by any chance ?


thanks

Djamé

javacom said...

Java_Xcode4_template2.zip - Google Drive - Google Docs
https://docs.google.com/file/d/0BzRf9KaSEld7TzBRY2c2VGZlRGs/edit

javacom said...
This comment has been removed by a blog administrator.
javacom said...

Java_Xcode4_template2.zip
https://mega.nz/file/ulwEmSRa#HCQC7O5gGGJefIMtNARjoRnVn4zUq8BN94O0Pi1MEe0