11 Replies Latest reply: Feb 9, 2006 9:53 AM by 843810 RSS

    Note: Recompile with -Xlint:deprecation for details.

    843810
      Hi Everybody,

      I am currently using the JDK1.5 Edition and whenever I compile the following piece of code :
      ===================================================================================
      import java.applet.Applet;
      import java.awt.*;

      public class Applet5 extends Applet
      {
           String s;
           Label l1;
      Checkbox c1, c2, c3, c4;

           public void init()
           {
                setLayout(new GridLayout(5,1));
                l1 = new Label(" ");
                c1 = new Checkbox("1");
                c2 = new Checkbox("2");
                c3 = new Checkbox("3");
                c4 = new Checkbox("4");
                add(c1);
                add(c2);
                add(c3);
                add(c4);
                add(l1);
           }

           public boolean action(Event e,Object o)
      {     
                int i=0;
      if(c1.getState())
                     i=i+1;
                if(c2.getState())
                     i=i+2;
                if(c3.getState())
                     i=i+3;
                if(c4.getState())
                     i=i+4;
           
                l1.setText(String.valueOf(i));
                return true;
           }
      };
      ===========================================================================
      I get this message :
      ---------- Compile ----------
      Note: Applet5.java uses or overrides a deprecated API.
      Note: Recompile with -Xlint:deprecation for details.

      Output completed (5 sec consumed) - Normal Termination
      ==============================================================================
      Can anybody please tell me what I am doing wrong and what "Recompile with -Xlint:deprecation for details." actually means?

      I will be really glad if anybody could help me on this fast.

      Also, I am able to execute the code the way I want, so really not able to figure out how the above "Compilation Note" affects my program and is there anything I need to care of ?

      Thanking you in anticpation.

      Yours truly,
      Bhavesh S.
        • 1. Re: Note: Recompile with -Xlint:deprecation for details.
          843810
          The message is telling you that you are using a deprecated API. A deprecated API means an API that you shouldn't be using because it has been replaced by something else. The code will still work for now but someday a future release may eliminate the deprecated API and then your code will break. It is a good idea to stay away from deprecated APIs. The message is telling you to invoke javac with the -Xlint:deprecation flag and it will tell you exactly what it is complaining about.
          • 2. Re: Note: Recompile with -Xlint:deprecation for details.
            843810
            I just took a look at your code and your event handling methodology has been obsolete as of JDK 1.1. You are supposed to be using ActionListeners instead of the deprecated action() method. I bet the book you are using is about 7 years behind the times. I would strongly advise you to get a new book.
            • 3. Re: Note: Recompile with -Xlint:deprecation for details.
              843810
              Thank-you for pointing out the exact source on why I am getting the "Note" message. I will make it a practice to use the latest API specification even while practising simple examples.

              Thank-you.
              • 4. Re: Note: Recompile with -Xlint:deprecation for details.
                843810
                Thank-you for your explanation. I have used the the following method to Compile now: "javac -Xlint: Applet5.java"
                However even now it is showing me the same Compilation messages:
                -----------------------------------------------------------------------------------------------
                Note: Applet5.java uses or overrides a deprecated API.
                Note: Recompile with -Xlint:deprecation for details.
                -----------------------------------------------------------------------------------------------
                I also tried using True, False, Yes, No as flag options after "Xlint:", but it didn't give the desired result. Is there any option of Xlint which I can use while Compilation which will then point out the exact source of error ? If possible can you give me the exact syntax I should be using to Compile so that I know the exact source of error?

                Also can I use that method to compile all of my Java files irrespective of they are using deprecated code or not ?

                Hope I am not asking for too much. Thanking you in antcipation.

                Yours truly,
                Bhavesh S.
                • 5. Re: Note: Recompile with -Xlint:deprecation for details.
                  843810
                  The flag is "-Xlint:deprecation" not "-Xlint: ". It should be
                      javac -Xlint:deprecation Applet5.java
                  • 6. Re: Note: Recompile with -Xlint:deprecation for details.
                    843810
                    Thanx for giving the exact syntax.

                    I will make it a practice to read & understand the error messages & not just read-through them, when I get one.

                    Thanks for the help.
                    • 7. Re: Note: Recompile with -Xlint:deprecation for details.
                      843810
                      I have also this message:
                      Note: Recompile with -Xlint:unchecked for details

                      could somebody help me.
                      • 8. Re: Note: Recompile with -Xlint:deprecation for details.
                        843810
                        erm i realy need to find out how to fix it it just keeps saying use a next compile xlink dec ..
                        • 9. Re: Note: Recompile with -Xlint:deprecation for details.
                          843810
                          When you compile it, do like what they said above and compile your program with
                          javac -Xlint:deprecation ProgramName.java
                          . This will show you what line you're using deprecated methods on. If you look your method up in the Java API, there'll be a note that said "Deprecated: such-and-such has been replaced by ..." (or something to that effect) that will tell you what method you should use instead.

                          And even if you get this warning message when you compile, you can ignore it - your program still compiled and will work. But as they said above, just be wary as the deprecated code you're using could be removed in future releases of Java.

                          Edited by: Casey_K on Nov 28, 2009 4:50 PM
                          • 10. Re: Note: Recompile with -Xlint:deprecation for details.
                            843810
                            I don't know how to explain it exactly, but it's just java's way of saying it found something that could go wrong in your program, but it'll compile it for you anyways. Compiling with
                            javac -Xlint:unchecked MyProgram.java
                            will let you see what line it found these "unsafe operations" on.
                            • 11. Re: Note: Recompile with -Xlint:deprecation for details.
                              843810
                              hi i am a new member for ths forum.....i am a student....i want to specify my proj prob to u....i am trying to perform face recognition using laplacian face...when i am trying to activate a web cam it is showing the error cannot find symbol,method setExtent...is there jany need to import any package...i am already using JMF......but still its showing an error message