HELP, exam VERY soon. 12 hours:(

Discussion in 'Mac Programming' started by Jasonbot, Nov 22, 2006.

  1. Jasonbot macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #1
    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();
    }
    }
    
     
  2. MacBoobsPro macrumors 603

    MacBoobsPro

    Joined:
    Jan 10, 2006
  3. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #3
    no! I'm studying now. the issue is actually with XCode itself :( error with ?developer/Private/Jam can anyone upload the file?
     
  4. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #4
    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.
     
  5. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #5
    Post as much detail as you can of the error. The chances are that the file is fine and you are doing something wrong.
     
  6. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #6
    Nope, I checked the file. it opens terminal and says "Missing file or directory: all" Just up the file and I'll bet it will work!
     
  7. gekko513 macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #7
    I doubt it'll help, but here you go
     

    Attached Files:

    • jam.zip
      File size:
      61.8 KB
      Views:
      11
  8. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #8
    :( Sorry. I was wrong. so is there another fix?
    here's the exact error: Command /Developer/Private/Jam failed with exit code 1
     
  9. gekko513 macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #9
    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?
     
  10. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #10
    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.
     
  11. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #11
    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?
     
  12. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #12
    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.
     
  13. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #13
    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>
     
  14. gekko513 macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #14
    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.
     

    Attached Files:

  15. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #15
    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?
     
  16. gekko513 macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #16
    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
     

    Attached Files:

  17. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #17
    it says: Main-Class: HELP
    //I got 2.4 intel build. Maybe that's the problem?? The PPC mac @ home has no issues...
     

    Attached Files:

  18. gekko513 macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #18
    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.
     

    Attached Files:

  19. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #19
    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.
     

    Attached Files:

  20. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #20
    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.
     
  21. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #21
    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.
     
  22. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #22
    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.
     
  23. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #23
    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.
     
  24. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #24
    But then why does it work in 2.1?? I feel pretty dumb now!
     
  25. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #25
    I've no idea. It should throw an error. Or you are not passing an int but are passing a real Object.
     

Share This Page