Page 1 of 2 12 LastLast
Results 1 to 20 of 25
Like Tree1Likes

Thread: Using or overriding a deprecated API; Recompile with -Xlint:deprecation for details

  1. #1
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Posts
    112
    Rep Power
    0

    Default Using or overriding a deprecated API; Recompile with -Xlint:deprecation for details

    Hello friends!

    I am using the biojava library and trying to read a fasta file from my computer. But I am facing difficulty in understainding the code. Plus, I am encountering the following exception, though I have checked the deprecated methods n classes on
    XML Code:
    http://www.biojava.org/docs/api/deprecated-list.html
    and could not find one in my code.


    Java Code:
    Note: G:\Summer, 2011\biojava\backup biojava\code provided by sir\Biojava Seq Code\SeqIO\src\seqio\ReadFasta.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.

    Java Code:
    package seqio;
    
    import org.biojava.bio.seq.*;
    import org.biojava.bio.seq.io.*;
    import java.io.*;
    import org.biojava.bio.*;
    import java.util.*;
    import org.biojava.bio.seq.db.SequenceDB;
    import org.biojava.bio.symbol.Alphabet;
    import org.biojava.bio.symbol.AlphabetManager;
     
    public class ReadFasta {
      public static void main(String[] args) {
           BufferedInputStream bi = null;
        String ProjectPath= System.getProperties().getProperty("user.dir");
        try {
     
          //create a buffered reader to read the sequence file specified by args[0]
     
    
          bi = new BufferedInputStream(new FileInputStream(ProjectPath+"G:\\Summer, 2011\\biojava\\backup biojava\\code provided by sir\\SampleFile\\fake.fasta"));
          //read the EMBL File
          Alphabet alpha = AlphabetManager.alphabetForName("DNA");
    
          SequenceDB db =SeqIOTools.readFasta(bi,alpha);
          SequenceIterator seqi= db.sequenceIterator();
          Sequence seq =seqi.nextSequence(); 
            //do stuff with the sequence
          System.out.println(seq.seqString());
      }catch (Exception ex) {
            //not in EMBL format
            ex.printStackTrace();
          }
        }
      
    }





    What are the possible reasons for this error?
    Moreover, why have we initialized the object to null value in the following statement?
    Java Code:
    BufferedInputStream bi = null;

    what task does the following statement perform?
    Java Code:
    String ProjectPath= System.getProperties().getProperty("user.dir");

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default

    "Recompile with -Xlint:deprecation for details."
    Doing that in your javac command will tell you what has been deprecated.

    bi is declared null possibly because it was supposed to be closed in a finally block of the try/catch (to close the file stream). The usual form of that block would be (note, skipped some catching):
    Java Code:
    finally {
        if (bi != null) {
            bi.close();
        }
    }
    If it wasn't initialised then the compiler would complain on the "if" line that bi had not been initialised.

    The last question...there are a bunch of System properties you can access. The user home directory ("user.dir") is one of them.

  3. #3
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Posts
    112
    Rep Power
    0

    Default

    "Recompile with -Xlint:deprecation for details."
    Doing that in your javac command will tell you what has been deprecated.
    But what is meant by Recompiling with -Xlint? And how to do that?
    What exactly is -Xlint?

  4. #4
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Posts
    112
    Rep Power
    0

    Default

    there are a bunch of System properties you can access. The user home directory ("user.dir") is one of them.
    And this code was provided by my teacher. I have pasted it in my program as it was, except for having changed the path of the file to be read. I s there any possibility that user.dir might not be present in my system, or might be present but in a different name?

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default

    How are you compiling?

    Assuming it's from the command line:
    javac -Xlint:deprecation <any other stuff you usually have> <files to compile>

  6. #6
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Posts
    112
    Rep Power
    0

    Default

    How are you compiling?

    Assuming it's from the command line
    I am using jdk and netbeans compiler. I don't know how to compile using command line

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default

    Quote Originally Posted by Nazneen Ali View Post
    And this code was provided by my teacher. I have pasted it in my program as it was, except for having changed the path of the file to be read. I s there any possibility that user.dir might not be present in my system, or might be present but in a different name?
    Nope.
    That applies in windows/linux/wherever (assuming the system has the concept of user home directories).
    Print out the value to see it (System.out.println(ProjectPath)).

    Quote Originally Posted by Nazneen Ali View Post
    I am using jdk and netbeans compiler. I don't know how to compile using command line
    Then you'll have to find out how to get Netbeans to do the same thing. I thought Netbeans highlighted those things in the code anyway.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default

    Quote Originally Posted by Nazneen Ali View Post
    I am using jdk and netbeans compiler. I don't know how to compile using command line
    Look in the project properties for Run --> Arguments (just below "Main Class")

    db

  9. #9
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Posts
    112
    Rep Power
    0

    Default

    I am using
    XML Code:
    http://www.skylit.com/javamethods/faqs/javaindos.html
    to compile my program but how shall I include the libraries I am using in my program?

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default

    javac -cp<list your libraries here> <etc etc>

  11. #11
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Posts
    112
    Rep Power
    0

    Default

    I am getting unpleasant messages in the command prompt and I am not getting them. I have attached a screenshot. Please check it out. Am I going on the right way while writing the commands. The page visible behind the command prompt window contains the instructions I am following to compile the program in command prompt. I have wrapped the instruction I was at, in red frame.
    Attached Thumbnails Attached Thumbnails Using or overriding a deprecated API; Recompile with -Xlint:deprecation for details-untitled.jpg  

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default

    You haven't set your PATH to your JDK bin directory, as described further down that page.

  13. #13
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Posts
    112
    Rep Power
    0

    Default

    Look in the project properties for Run --> Arguments (just below "Main Class")

    db
    yeah.. but the text field against "Argument" is empty. What should I do with it?

  14. #14
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by Nazneen Ali View Post
    yeah.. but the text field against "Argument" is empty. What should I do with it?
    Uhm, type in the arguments you wish to use?

  15. #15
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by masijade View Post
    Uhm, type in the arguments you wish to use?
    That is so bourgeois ...

    kindest regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  16. #16
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default

    Quote Originally Posted by JosAH View Post
    That is so bourgeois ...

    kindest regards,

    Jos ;-)
    Wanna argue the point?

    db <-- dons brass knuckles

  17. #17
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by DarrylBurke View Post
    Wanna argue the point?

    db <-- dons brass knuckles
    Please, don't be so prophane ...

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  18. #18
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Posts
    112
    Rep Power
    0

    Default

    @ Jos and DerrylBurke:

    Yeah I'll enjoy your argument but pleassssseeee solve my problem first Please explain me in the easiest possible way the reason for which I am confronting these exceptions and how to help them.

    The code is as follows:
    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package seqio;
    
    import org.biojava.bio.seq.*;
    import org.biojava.bio.seq.io.*;
    import java.io.*;
    import org.biojava.bio.*;
    import java.util.*;
    import org.biojava.bio.seq.db.SequenceDB;
    import org.biojava.bio.symbol.Alphabet;
    import org.biojava.bio.symbol.AlphabetManager;
     
    public class ReadFasta {
      public static void main(String[] args) {
           BufferedInputStream bi = null;
        String ProjectPath= System.getProperties().getProperty("user.dir");
        System.out.println(ProjectPath);
        try {
     
          //create a buffered reader to read the sequence file specified by args[0]
     
    
          bi = new BufferedInputStream(new FileInputStream(ProjectPath+"\\SampleFile\\fake.fasta"));
          //read the EMBL File
          Alphabet alpha = AlphabetManager.alphabetForName("DNA");
    
          SequenceDB db =SeqIOTools.readFasta(bi,alpha);
          SequenceIterator seqi= db.sequenceIterator();
          Sequence seq =seqi.nextSequence(); 
            //do stuff with the sequence
          System.out.println(seq.seqString());
      }catch (Exception ex) {
            //not in EMBL format
            ex.printStackTrace();
          }
        }
      
    }

    The output I get is as follows:

    init:
    deps-jar:

    Compiling 1 source file to G:\Summer, 2011\biojava\backup biojava\code provided by sir\Biojava Seq Code\SeqIO\build\classes

    Note: G:\Summer, 2011\biojava\backup biojava\code provided by sir\Biojava Seq Code\SeqIO\src\seqio\ReadFasta.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.

    compile-single:
    run-single:

    G:\Summer, 2011\biojava\backup biojava\code provided by sir\Biojava Seq Code\SeqIO
    agacctcgtacaggcaaccccttgtagtatcatggcgggtgcagcttgta ctagcctacggcgtgatgcatggtatacacctgtataggctgcacggatc gccggtactctgacggtcaccaatgcttatataccccgtgctgagagcgg gaccccgaaaattaaggagggcccagattcatcgagatgccagtgtatgt tgagtcttcaggttagtagtaacaactcgatctgttgagccgatcctaca atgttacttcgtccattgccacgggcgcaccgcaaatacggggcaaggct tggcagtaattctgcgtctcgcagtgaccgatggtgggggaggtagccgc ttccaagaatgtagtaattccggcaatccggcgagtaattgcgcagagtg ccacggatccgcacatagctctatatcacgagtcgcgcagtgctttcggg cgtttgagattagacactagtttagtcactctccatgcgacatgtcaccg aacgatggaatacatagaattataagttgcagctcagaaacagaatgaaa tcactgcttgggcaatttcattcttttaccattcgtttagcttatacgaa ccacgatggagtacctcgggttccaccctcatgtcacggataaaacctta ggtgctcctgcaatcgatctcatgtatgccccactcagatttaaatccgc tttgtggacgggaatacaaagttccgaggtcgtccgtgttggcaatccta gaaccctgcagcattgcggatgtcgtcccattgacacttgagatggttgc gcgtccgaacatgaacacttcgctcctcaggcggagctaaaatcaatcag taacgagcgcagtctaatggttgtaacctgctgccaagtacacctgcctc tccgatgtggctcgacgctgtgccgaaatcttcgctttagccggataccc taacttcttaagcagagttacggcaaaggggaaacgacaatggcgccgcg

    BUILD SUCCESSFUL (total time: 0 seconds)



    I am simply unable to find out which class or method is deprecated. If I would, I would have checked in the API and find the method/class which has replaced the deprecated one. Can the error be about libraries I have used?

  19. #19
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    enter

    -Xlint:deprecation

    into the aforementioned "textbox" and recompile already. I don't know what is so hard to understand.

  20. #20
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

Page 1 of 2 12 LastLast

Similar Threads

  1. -Xlint / -Deprecation Error
    By seejay in forum New To Java
    Replies: 3
    Last Post: 01-15-2011, 12:25 AM
  2. xlint full form
    By java4susant in forum New To Java
    Replies: 0
    Last Post: 10-27-2010, 03:08 AM
  3. unchecked or unsafe operations-Recompile with -Xlint
    By pronetin in forum Advanced Java
    Replies: 15
    Last Post: 05-31-2010, 06:41 PM
  4. How was deprecation handled before annotations ?
    By ajeeb in forum New To Java
    Replies: 0
    Last Post: 03-20-2009, 12:44 PM
  5. Do I have to recompile everything?
    By wntdaliv in forum New To Java
    Replies: 1
    Last Post: 01-24-2009, 04:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •