Win a copy of Functional Design and Architecture this week in the Functional programming 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to identify deprecated API

 
Greenhorn
Posts: 19
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic