Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • 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: 21923
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 69035
275
  • Mark post as helpful
  • send pies
  • 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: 12838
52
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Edit: too slow (and predictable)!
 
Campbell Ritchie
Marshal
Posts: 69035
275
  • Mark post as helpful
  • send pies
  • 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: 21923
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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: 69035
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But very occasionally, I manage to get in before Rob
 
Rob Spoor
Sheriff
Posts: 21923
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually when I'm off doing real work, instead of, well, being Campbell
 
Campbell Ritchie
Marshal
Posts: 69035
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote: . . . well, being Campbell

Have you ever been Campbell?
 
Rob Spoor
Sheriff
Posts: 21923
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried, but I didn't really like it
 
Campbell Ritchie
Marshal
Posts: 69035
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried it too, but seem to have liked it more than you.
 
Rob Spoor
Sheriff
Posts: 21923
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would definitely hope so!
 
Legend has it that if you rub the right tiny ad, a genie comes out.
Try Free Java/.NET Libraries for Word Excel PowerPoint and PDF
htttp://www.e-iceblue.com/free-apis.html
    Bookmark Topic Watch Topic
  • New Topic