Note: Recompile with -Xlint:deprecation for details.

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.

[1816 byte] By [2learnJavaa] at [2007-10-2 11:47:41]
# 1

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.

Gita_Weinera at 2007-7-13 6:02:16 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

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.

Gita_Weinera at 2007-7-13 6:02:16 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3
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.
2learnJavaa at 2007-7-13 6:02:16 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4

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.

2learnJavaa at 2007-7-13 6:02:16 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5
The flag is "-Xlint:deprecation" not "-Xlint: ". It should be javac -Xlint:deprecation Applet5.java
Gita_Weinera at 2007-7-13 6:02:16 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 6
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.
2learnJavaa at 2007-7-13 6:02:16 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 7
I have also this message:Note: Recompile with -Xlint:unchecked for detailscould somebody help me.
YouBugMea at 2007-7-13 6:02:16 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...