Results 1 to 3 of 3

Thread: Compile Error

  1. #1
    StevenR is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Default Compile Error

    Can somebody check and tell me what the issue is. I get this compiling error and I have no idea what it is telling me. I checked with my teacher and he said the code is correct but it will not compile.
    Java Code:
    C:\Users\Steven Reiche\Documents\JAVA\HomeWork\Chapter 2\TextPad>javac Age.java
    Age.java:19: error: cannot find symbol
              age = Integer.parseInt(str);
                           ^
      symbol:   method parseInt(String)
      location: class Integer
    1 error
    Here is the program code
    Java Code:
    import javax.swing.JOptionPane;
    
    /**
       This program will display an input dialog asking the user
       to input his or her age.
       Then convert the input value to an int and store it in an int variable named age
    */
    
    public class Age
    {
       public static void main(String[] args)
       {
          String str;
    	  int age;
    
    		//Ask to input age
    	  str = JOptionPane.showInputDialog("How old are you?");
    	   //convert age to Int
    	  age = Integer.parseInt(str);
    
    
    
    
          // Display the age
          JOptionPane.showMessageDialog(null, "The age you entered is " + age);
    
          System.exit(0);
       }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,882
    Rep Power
    8

    Default Re: Compile Error

    I do not get that error when compiling. Are you sure you're compiling the correct file?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,854
    Rep Power
    19

    Default Re: Compile Error

    You haven't got an Integer.java file located in that directory have you?
    Failing that, is there a CLASSPATH defined in the environment variables?
    If so, then that could be the problem.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Compile error :(
    By Astralogic in forum New To Java
    Replies: 10
    Last Post: 07-22-2013, 02:26 PM
  2. i get this error during compile
    By Bibin in forum New To Java
    Replies: 1
    Last Post: 12-24-2011, 08:43 AM
  3. compile error
    By missmara77 in forum New To Java
    Replies: 1
    Last Post: 10-31-2011, 07:48 PM
  4. Compile Error
    By gcorreageek in forum Advanced Java
    Replies: 2
    Last Post: 09-08-2010, 05:23 AM
  5. Compile Error - Please Help!!
    By AJ2009 in forum New To Java
    Replies: 10
    Last Post: 01-04-2009, 03:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •