Results 1 to 4 of 4
  1. #1
    rsjac is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Talking [solved]

    Hi, I am starting compsci at Uni this year and wanted to get a head start on java so I have been going through a series of java video tutorials. They are really simple, but on the second program I got an error that prevents my program compiling. The full code of the program is

    Java Code:
    import java.awt.Frame;
    import java.awt.label;
    public class HowdyWindow extends Frame {
    	public static void main(String arg[]) {
    		new HowdyWindow();
    	}
    	HowdyWindow() {
    		Label label;
    		label = new Label("Howdy!");
    		add(label);
    		pack();
    		show();
    	}
    }
    And the error I receive when compiling is

    C:\jwork\HowdyWindow>javac HowdyWindow.java
    Hodyindow.java:2: cannot find symbol
    symbol : class label
    location: package java.awt
    import java.awt.label;
    ^
    HowdyWindow.java:8: cannot find symbol
    symbol : class Label
    location: class HowdyWindow
    Label label;
    ^
    HowdyWindow.java:9: cannot find symbol
    symbol : class Label
    location: class HowdyWindow
    label = new Label("Howdy!");
    ^

    Note: HowdyWindow.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details
    3 errors

    Like I said, I am brand spanking new to java and coding in general, so I have no idea what I did wrong. My text editor is NotePad++.
    The code looks to me exactly the same as the sample code in the video.

    Any advice would be a big help. Thanks!

    Edit: the ^ arrows don't want to point where they are told. The first points at the . after java.awt
    the second points at the L in Label label;
    and the third at the L in label = new Label
    Last edited by rsjac; 02-21-2011 at 05:26 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    java.awt.label is different from java.awt.Label. Spelling and cApItAliZaTion matter and the latter is the correct one.

    much luck!

  3. #3
    rsjac is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default

    Thanks!

    Could have sworn it was all right, but no such luck. Cmd still says that it uses or overrides a deprecated API but it compiled it anyway and it ran as it should have. Continue with the tutorials I shall

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    You get 2 types of messages when compiling

    Errors which must be corrected.

    Warnings which you can choose to ignore. The code will still compile and run but is is highly encouraged that you try and fix them. Especially if you are using something which is deprecated. If you read the Java API for the class/method which is deprecated it will provide advice as to what you should use instead.

Similar Threads

  1. Replies: 1
    Last Post: 01-07-2011, 06:33 AM
  2. Newb here, need help with JSP.
    By grep in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-25-2010, 10:04 PM
  3. Replies: 1
    Last Post: 03-29-2010, 02:07 AM
  4. Total number of reserved words in java
    By vivvy in forum New To Java
    Replies: 1
    Last Post: 02-06-2010, 04:18 PM
  5. Java newb Q: 8-digit id
    By 1111FM in forum New To Java
    Replies: 2
    Last Post: 09-29-2008, 03:37 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
  •