Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jasonbot

macrumors 68020
Original poster
Aug 15, 2006
2,467
0
The Rainbow Nation RSA
I'm having problems with my for loop. Please assist me quickly. THANKS!

Code:
//java study

import javax.swing.*;

public class HELP
{
	public HELP()
{

		for(int i=1; i<=20;i++)
		{
			JOptionPane.showMessageDialog(null,i);
		}
		
}
public static void main (String args[])
{
	new HELP();
}
}
 

Jasonbot

macrumors 68020
Original poster
Aug 15, 2006
2,467
0
The Rainbow Nation RSA
Bump, please help me quickly... I know that this board is very not active right now but any help is good. All I need is that one Xcode file. All you have to do is attach it to your post.
 

gekko513

macrumors 603
Oct 16, 2003
6,301
1
:( Sorry. I was wrong. so is there another fix?

I don't know. We need more details. I've never done Java in Xcode, so I may not be of any help, anyway, but to have a chance of helping we need to know what you've done so far in Xcode. How did you create the project and what kind of project is it? Are there other files in the project. Have you done any changes to the project settings, if so, what? When does the error come up, and do you have any more info about the error?
 

Jasonbot

macrumors 68020
Original poster
Aug 15, 2006
2,467
0
The Rainbow Nation RSA
I don't know. We need more details. I've never done Java in Xcode, so I may not be of any help, anyway, but to have a chance of helping we need to know what you've done so far in Xcode. How did you create the project and what kind of project is it? Are there other files in the project. Have you done any changes to the project settings, if so, what? When does the error come up, and do you have any more info about the error?

It's pretty longwinded but here we go:

>Make a JOptionPane.showMessageDialog(null, variable );
>the variable must be a number/character
>ERROR APPEARS!
>JOptionPane works great with Strings though :(

It's a basic ant based java and my original post is the entire code.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
OK. How did you get this Java into XCode? I mean step by step like:

Open XCode
Start New Project via menu item
Choose <Project Type>

Jam is part of the build system in XCode and something about your project is making it upset. As you seem to be compiling a simple single file could you not just use javac in Terminal?
 

Jasonbot

macrumors 68020
Original poster
Aug 15, 2006
2,467
0
The Rainbow Nation RSA
OK. How did you get this Java into XCode? I mean step by step like:

Open XCode
Start New Project via menu item
Choose <Project Type>

Jam is part of the build system in XCode and something about your project is making it upset. As you seem to be compiling a simple single file could you not just use javac in Terminal?

open xcode
Start New Project via menu item
new java tool
selsct desktop as save location
paste skeleton code
insert for loop typing but ignoring code completion
ERROR when compiling.

//javac works but it's a hassle I want Xcode to work with it's error correction and all.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
OK. What did you name the tool? Basically does the classname match the filename (it won't work otherwise).

You could just compile it on the command line with javac:

Open Terminal
cd Desktop
javac <filename>
 

gekko513

macrumors 603
Oct 16, 2003
6,301
1
open xcode
Start New Project via menu item
new java tool
selsct desktop as save location
paste skeleton code
insert for loop typing but ignoring code completion
ERROR when compiling.

//javac works but it's a hassle I want Xcode to work with it's error correction and all.

Works fine here. Are you sure you don't get another error, too? I got a failed build at first because I forgot to use the same name for the constructor and the class, and that gave me two errors, the first was the one you're describing and the second was the error for the wrong constructor name.
 

Attachments

  • Picture 5.png
    Picture 5.png
    12 KB · Views: 489

Jasonbot

macrumors 68020
Original poster
Aug 15, 2006
2,467
0
The Rainbow Nation RSA
the tool name? the whole file is called "HELP"
I know how to compile in terminal. it works! but XCode doesn't.

//what XCode version do you have? and what steps did you go through?
 

gekko513

macrumors 603
Oct 16, 2003
6,301
1
OK, can you post a screenshot of the same content that I have in my attached screenshot. Make sure the project is selected in the left pane. Then, also double click on the Manifest file and say what it says. Mine says: Main-Class: JavaTest

Edit: Xcode version 2.2.1
1) New Project -> Java Tool -> Project name: JavaTest
2) Cut and paste from your code into JavaTest.java
3) Edited the pasted code so that it says JavaTest instead of HELP
4) Build, got error because I forgot to rename the constructor
5) Rename constructor
6) Build, success
7) Run, success, screen capture, post macrumors post
 

Attachments

  • Picture 6.png
    Picture 6.png
    24.3 KB · Views: 92

Jasonbot

macrumors 68020
Original poster
Aug 15, 2006
2,467
0
The Rainbow Nation RSA
it says: Main-Class: HELP
//I got 2.4 intel build. Maybe that's the problem?? The PPC mac @ home has no issues...
 

Attachments

  • Picture 2.png
    Picture 2.png
    28.4 KB · Views: 80

gekko513

macrumors 603
Oct 16, 2003
6,301
1
OK, that looks good. How about a screen shot of the error window after a "Build". This is how mine looks if I introduce an error in the code.
 

Attachments

  • Picture 8.png
    Picture 8.png
    33.9 KB · Views: 77

Jasonbot

macrumors 68020
Original poster
Aug 15, 2006
2,467
0
The Rainbow Nation RSA
I think XCode must be broken! This sucks! iMac G5 is running 2.1 no hitch! iMac C2D 2.4 PROBLEMS, this really sucks. <Refering to the currents situation.
 

Attachments

  • Picture 4.png
    Picture 4.png
    43.3 KB · Views: 89

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I think XCode must be broken! This sucks! iMac G5 is running 2.1 no hitch! iMac C2D 2.4 PROBLEMS, this really sucks. <Refering to the currents situation.

OK so it's clear that there is a problem with the line it's highlighted. There is a symbol on that line that the compiler does not recognise. Most likely it cannot find JOptionPane. Have you double checked the capitalisation, spelling etc of the class and method.

XCode is not broken.
 

Jasonbot

macrumors 68020
Original poster
Aug 15, 2006
2,467
0
The Rainbow Nation RSA
robbieduncan said:
OK so it's clear that there is a problem with the line it's highlighted. There is a symbol on that line that the compiler does not recognise. Most likely it cannot find JOptionPane. Have you double checked the capitalisation, spelling etc of the class and method.

XCode is not broken.

Code:
//java study

import javax.swing.*;

public class test
{
	public test()
{
		
		int i=1;
		JOptionPane.showMessageDialog(null,i);
		
		
}
public static void main (String args[])
{
	new test();
}
}

no one can go wrong with that /\/\/\ basically xcode is busted. the update (2.4.1) is like a gig. and my crappy south african cap is only one gig. so this must be one of "those bugs" that was fixed in the update.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
no one can go wrong with that /\/\/\ basically xcode is busted. the update (2.4.1) is like a gig. and my crappy south african cap is only one gig. so this must be one of "those bugs" that was fixed in the update.

The chances of that are vanishingly small. It's much more likely that you are using the wrong SDK, have not included the correct path to Swing or something similar.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
So instead of blaming the tools I tried compiling it on the command line (OK on Solaris as I'm at work) and got this error:

test.java:12: cannot resolve symbol
symbol : method showMessageDialog (<nulltype>,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null,i);
^
1 error

Which seems to be the same as the screenshot you posted: cannot resolve symbol.

The answer is very simple: there is no showMessageDialog method that takes Object, int. It takes an Object as it's second paramater. An int is a primitive type in Java. It's not an Object. This is a basic, fundamental problem with your understanding, and not any issue with XCode as I've said all along.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.