• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to identify deprecated API  RSS feed

 
Greenhorn
Posts: 19
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i need to identify deprecated api in java files in a given directory which are belong to java1.3 or 1.4 apis and my target jdk version 1.7 and need to write the message printed on the console to a file.

i know i can use -Xlint option but it will print on the console. How to get the message from console to a string so that i can write it to a file

Could anyone please help me to get the work started.
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply redirect the output of the compiler to a file, for example:

javac MyProgram.java > result.txt
 
Tej Ernesto
Greenhorn
Posts: 19
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, the file is created but no text in it, which was printed on the console
 
Tej Ernesto
Greenhorn
Posts: 19
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jesper de Jong

when i compiled my file using the command



it produced warnings



but the warning is not captured in the txt file, where as when i run the file useing


then what was printed on the console was written to txt file.

So i need the warnings to be written to txt file
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to redirect the error stream, not the output stream, so use 2> instead of >

For a more detailed description, see this page: Redirecting Error Messages from Command Prompt: STDERR/STDOUT

Edit: that's if you're on Windows. Linux probably has something similar, but I'm not a Linux user.
 
Tej Ernesto
Greenhorn
Posts: 19
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Darryl Burke that was really helpful..
I can use this command to run it from the command prompt. What if i want to use it in my web application where i will scan all the java files in a directory and compile them and capture all warnings to a file.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!