• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

What is -Xlint in compiling java program?why this is done?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i compile my sql program. i come across these error please help me
\\code
public class main {
^
Note: C:\Users\Admin\Desktop\MySQLAccess.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
\\code
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the javac page-


-deprecation
Show a description of each use or override of a deprecated member or class. Without -deprecation, javac shows a summary of the source files that use or override deprecated members or classes. -deprecation is shorthand for -Xlint:deprecation.



can you show us the code? You have used some deprecated methods or classes due to which the compiler is suggesting to compile with the deprecation option so that you can remove these deprecated usages. Deprecated code is the one that would be removed in the next release of JDK.
 
annamaneni sampath
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried compiling that. Firstly I hit an error because main is a public class, so needs to be in its own file. That can be fixed just by removing the public, though.

Then, with -Xlint:deprecation added to the compiler arguments, you get this message:

warning: [deprecation] Date(int,int,int) in java.sql.Date has been deprecated
preparedStatement.setDate(4, new java.sql.Date(2009, 12, 11));



Looking at the Javadocs for java.sql.Date, you can see that the constructor that takes a year/month/day has been deprecated. You should use the other constructor that takes a long value. And you can construct the long value using the Calendar class. Something like:

By the way, before you get caught up in the trap - your month value is 12. Months are zero-indexed in Java!
 
Sheriff
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be more precise, months are Calendar.JANUARY based. Now that happens to be 0, but it shows you that you should use Calendar.JANUARY, Calendar.FEBRUARY, ..., Calendar.DECEMBER instead of 0, 1, ..., 11. The latter will confuse people (they'll think 11 is November, not December), using Calendar.DECEMBER won't.
 
Marshal
Posts: 74381
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The tool lint is a long-established tool for finding errors and bugs in code. I don't know why it is called lint.
 
lowercase baba
Posts: 13014
66
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:The tool lint is a long-established tool for finding errors and bugs in code. I don't know why it is called lint.


The term was derived from the name of the undesirable bits of fiber and fluff found in sheep's wool.

--Wikipedia
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edit: too slow (and predictable)!
 
Campbell Ritchie
Marshal
Posts: 74381
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, both of you.

Fred rarely beats me . . . now, Rob Spoor, that's a different story.
 
Rob Spoor
Sheriff
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's my biggest hobby, beating Campbell. I especially like it when the difference is just a few seconds.
 
Campbell Ritchie
Marshal
Posts: 74381
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But very occasionally, I manage to get in before Rob
 
Rob Spoor
Sheriff
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually when I'm off doing real work, instead of, well, being Campbell
 
Campbell Ritchie
Marshal
Posts: 74381
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote: . . . well, being Campbell

Have you ever been Campbell?
 
Rob Spoor
Sheriff
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried, but I didn't really like it
 
Campbell Ritchie
Marshal
Posts: 74381
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it too, but seem to have liked it more than you.
 
Rob Spoor
Sheriff
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would definitely hope so!
 
reply
    Bookmark Topic Watch Topic
  • New Topic