Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Java Q: Code runs in Eclipse but not xcode! Any ideas?

Java Q: Code runs in Eclipse but not xcode! Any ideas?
Thread Tools
Fresh-Faced Recruit
Join Date: Oct 2002
Location: Wisconsin, United States
Status: Offline
Reply With Quote
Sep 13, 2006, 09:33 AM
 
I'm taking a java course at school and the professor uses eclipse to build and run. I was able to get my fraction program working on eclipse but when I tried to transfer it over to xcode it builds fine but doesn't actually output anything to the console except:

Exception in thread "main" java.lang.NoSuchMethodError: main

I'm not really sure what's going on. I have two files, a Fraction.java and FractionTester.java. Fraction is a class that handles operations you might want to perform with fractions and FractionTester allows the user to input fractions and then sends them to Fraction.

I can post code if anyone thinks it might be helpful.

These are the steps I used to create a Java project in xcode.

1) new project
2) ant based java project
3) dumped my two .java files into the source directory
4) build and run

Ideas?
     
Fresh-Faced Recruit
Join Date: Aug 2005
Status: Offline
Reply With Quote
Sep 13, 2006, 02:21 PM
 
You can't just dump the Java files in the Source directory. You have to add them to the project. Choose Project > Add to Project to add the files to your project.

If adding the Java files to your project doesn't fix the problem, try creating a Java Tool project. If that doesn't work, you'll need to post code.
Mark Szymczyk
Author, Xcode Tools Sensei
http://www.meandmark.com
     
Kajo  (op)
Fresh-Faced Recruit
Join Date: Oct 2002
Location: Wisconsin, United States
Status: Offline
Reply With Quote
Sep 13, 2006, 03:03 PM
 
I can add the files via the method you detailed but they just show up in the project directory, not the source directory. I tried dragging them into the source folder but that doesn't work either as they don't appear draggable. When I build and run I just get the default "Hello World" message from the default content of the one source file.
     
Fresh-Faced Recruit
Join Date: Aug 2005
Status: Offline
Reply With Quote
Sep 13, 2006, 04:18 PM
 
When you add the files to the project, a sheet opens. There is a checkbox at the top of the sheet that says Copy Items into destination group's folder if needed. Select that checkbox.

In the project window you will see the files in two places: the project directory and the src folder. You can delete the files from the project directory. You should be able to build the project now.

If you still have problems, I would suggest creating a Java Tool project and see if you can compile your code in a Java Tool project.
Mark Szymczyk
Author, Xcode Tools Sensei
http://www.meandmark.com
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:59 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2