 |
 |
Java Q: Code runs in Eclipse but not xcode! Any ideas?
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Oct 2002
Location: Wisconsin, United States
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Oct 2002
Location: Wisconsin, United States
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |