Deprecated API compilation error

Please help. Attached is my source code. I'm receiving a compilation error that reads 'RnrBooksApp.java uses or overrides a deprecated API. Recompile with -deprecation for details.' I'm very new to Java, so I appreciate any assistance. Thank you!
//ClassName: RnrBooksApp
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class RnrBooksApp extends Frame implements ItemListener, ActionListener
     //Declare database variables
     Connection conBook;
     Statement cmdBook;
     ResultSet rsBook;
     boolean blnSuccessfulOpen = false;
     //Declare components
     Choice lstBooks               = new Choice();
     TextField txtISBN          = new TextField(13);
     TextField txtTitle          = new TextField(50);
     TextField txtAuthor = new TextField(30);
     TextField txtPublisher     = new TextField(30);
     Button btnAdd      = new Button("Add");
     //Button btnUpdate = new Button("Update");
     Button btnEdit     = new Button("Save");
     Button btnCancel = new Button("Cancel");
     Button btnDelete = new Button("Delete");
     Label lblMessage = new Label(" ");
     public static void main(String args[])
          //Declare an instance of this application
          RnrBooksApp thisApp = new RnrBooksApp();
          thisApp.createInterface();
     public void createInterface()
          //Load the database and set up the frame
          loadDatabase();
          if (blnSuccessfulOpen)
               //Set up frame
               setTitle("Books Database");
               addWindowListener(new WindowAdapter()
                              public void windowClosing(WindowEvent event)
                              stop();
                              System.exit(0);
               setLayout(new BorderLayout());
               //Set up top panel
               Panel pnlTop = new Panel(new GridLayout(2, 2, 10, 10));
               pnlTop.add(new Label("ISBN"));
               lstBooks.insert("Select a Book to Display", 0);
               lstBooks.addItemListener(this);
               pnlTop.add(lstBooks);
               pnlTop.add(new Label(" "));
               add(pnlTop, "North");
               //Set up center panel
               Panel pnlMiddle = new Panel(new GridLayout(5, 2, 10, 10));
               pnlMiddle.getInsets();
               pnlMiddle.add(new Label("ISBN"));
               pnlMiddle.add(txtISBN);
               pnlMiddle.add(new Label("Title"));
               pnlMiddle.add(txtTitle);
               pnlMiddle.add(new Label("Author"));
               pnlMiddle.add(txtAuthor);
               pnlMiddle.add(new Label("Publisher"));
               pnlMiddle.add(txtPublisher);
               setTextToNotEditable();
               Panel pnlLeftButtons = new Panel(new GridLayout(0, 2, 10, 10));
               Panel pnlRightButtons = new Panel(new GridLayout(0, 2, 10, 10));
               pnlLeftButtons.add(btnAdd);
               btnAdd.addActionListener(this);
               pnlLeftButtons.add(btnEdit);
               btnEdit.addActionListener(this);
               pnlRightButtons.add(btnDelete);
               btnDelete.addActionListener(this);
               pnlRightButtons.add(btnCancel);
               btnCancel.addActionListener(this);
               btnCancel.setEnabled(false);
               pnlMiddle.add(pnlLeftButtons);
               pnlMiddle.add(pnlRightButtons);
               add(pnlMiddle, "Center");
               //Set up bottom panel
               add(lblMessage, "South");
               lblMessage.setForeground(Color.red);
               //Display the frame
               setSize(400, 300);
               setVisible(true);
          else
               stop(); //Close any open connection
               System.exit(-1); //Exit with error status
     public Insets insets()
          //Set frame insets
          return new Insets(40, 15, 15, 15);
     public void loadDatabase()
          try
               //Load the Sun drivers
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          catch (ClassNotFoundException err)
               try
               //Load the Microsoft drivers
               Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver");
               catch (ClassNotFoundException error)
               System.err.println("Drivers did not load properly");
          try
               //Connect to the database
               conBook = DriverManager.getConnection("jdbc:odbc:Book");
               //Create a ResultSet
               cmdBook = conBook.createStatement();
               rsBook = cmdBook.executeQuery(
                    "Select * from Book;");
               loadBooks(rsBook);
               blnSuccessfulOpen = true;
          catch(SQLException error)
               System.err.println("Error: " + error.toString());
     public void loadBooks(ResultSet rsBook)
          //Fill ISBN list box
          try
               while(rsBook.next())
               lstBooks.add(rsBook.getString("ISBN"));
          catch (SQLException error)
               System.err.println("Error in Display Record." + "Error: " + error.toString());
     public void itemStateChanged(ItemEvent event)
          //Retrieve and display the selected record
          String strISBN = lstBooks.getSelectedItem();
          lblMessage.setText(""); //Delete instructions
          try
               rsBook = cmdBook.executeQuery(
                    "Select * from Book where [ISBN] = '"
                    + strISBN + "';");
               txtISBN.setText(strISBN);
               displayRecord(rsBook);
               setTextToEditable();
          catch(SQLException error)
               lblMessage.setText("Error in result set. " + "Error: " + error.toString());
     public void displayRecord(ResultSet rsBook)
          //Display the current record
          try
               if(rsBook.next())
                    txtTitle.setText(rsBook.getString("Title"));
                    txtAuthor.setText(rsBook.getString("Author"));
                    txtPublisher.setText(rsBook.getString("Publisher"));
                    lblMessage.setText("");
               else
                    lblMessage.setText("Record not found");
                    clearTextFields();
          catch (SQLException error)
               lblMessage.setText("Error: " + error.toString());
     public void actionPerformed(ActionEvent event)
          //Test the command buttons
          Object objSource = event.getSource();
          if(objSource == btnAdd && event.getActionCommand () == "Add")
               Add();
          else if (objSource == btnAdd)
               Save();
          else if(objSource == btnEdit)
               Edit();
          else if(objSource == btnDelete)
               Delete();
          else if(objSource == btnCancel)
               Cancel();
     public void setTextToNotEditable()
          //Lock the text fields
          txtISBN.setEditable(false);
          txtTitle.setEditable(false);
          txtAuthor.setEditable(false);
          txtPublisher.setEditable(false);
     public void setTextToEditable()
          //Unlock the text fields
          txtISBN.setEditable(true);
          txtTitle.setEditable(true);
          txtAuthor.setEditable(true);
          txtPublisher.setEditable(true);
     public void clearTextFields()
          //Clear the text fields
          txtISBN.setText("");
          txtTitle.setText("");
          txtAuthor.setText("");
          txtPublisher.setText("");
     public void Add()
          //Add a new record
          lblMessage.setText(" ");     //Clear previous message
          setTextToEditable();                //Unlock the text fields
          clearTextFields();                //Clear text field contents
          txtISBN.requestFocus ();
          //Set up the OK and Cancel buttons
          btnAdd.setLabel("OK");
          btnCancel.setEnabled(true);
          //Disable the Delete and Edit buttons
          btnDelete.setEnabled(false);
          btnEdit.setEnabled(false);
     public void Save()
                    //Save the new record
                    // Activated when the Add button has an "OK" label
                    if (txtISBN.getText().length ()== 0 || txtAuthor.getText().length() == 0)
                         lblMessage.setText("The ISBN or Author is blank");
                    else
                         try
                              cmdBook.executeUpdate("Insert Into Book "
                                        + "([ISBN], [Title], [Author], [Publisher]) "
                                        + "Values('"
                                        + txtISBN.getText() + "', '"
                                        + txtTitle.getText() + "', '"
                                        + txtAuthor.getText() + "', '"
                                        + txtPublisher.getText() + "')");
                              //Add to name list
                              lstBooks.add(txtISBN.getText());
                              //Reset buttons
                              Cancel();
                         catch(SQLException error)
                              lblMessage.setText("Error: " + error.toString());
     public void Delete()
                    //Delete the current record
                    int intIndex = lstBooks.getSelectedIndex();
                    String strISBN = lstBooks.getSelectedItem();
                    if(intIndex == 0)          //Make sure a record is selected
                                                  //Position 0 holds a text message
                         lblMessage.setText("Please select the record to be deleted");
                    else
                         //Delete the record from the database
                         try
                              cmdBook.executeUpdate(
                                   "Delete from Book where [ISBN] = '" + strISBN + "';");
                              clearTextFields();               //Delete from screen
                              lstBooks.remove(intIndex);          //Delete from list
                              lblMessage.setText("Record deleted");     //Display message
                         catch(SQLException error)
                              lblMessage.setText("Error during Delete."
                                   + "Error: " + error.toString());
     public void Cancel()
                    //Enable the Delete and Edit buttons
                    btnDelete.setEnabled(true);
                    btnEdit.setEnabled(true);
                    //Disable the Cancel button
                    btnCancel.setEnabled(false);
                    //Change caption of button
                    btnAdd.setLabel("Add");
                    //Clear the text fields and status bar
                    clearTextFields();
                    lblMessage.setText("");
     public void Edit()
                    //Save the modified record
                    int intIndex = lstBooks.getSelectedIndex();
                    if(intIndex == 0)          //Make sure a record is selected
                                                  //Position 0 holds a text message
                         lblMessage.setText("Please select the record to change");
                    else
                         String strISBN = lstBooks.getSelectedItem();
                         try
                              cmdBook.executeUpdate("Update Book "
                                   + "Set [ISBN] = '" + txtISBN.getText() + "', "
                                   + "[Title] = '" + txtTitle.getText() + "', "
                                   + "[Author] = '" + txtAuthor.getText() + "', "
                                   + "[Publisher] = '" + txtPublisher.getText() + "' "
                                   + "Where [ISBN] = '" + strISBN + "';");
                              if (!strISBN.equals(txtISBN.getText()))
                                   //Last name changed; change the list
                                   lstBooks.remove(intIndex); //Remove the old entry
                                   lstBooks.add(txtISBN.getText()); //Add the new entry
                         catch(SQLException error)
                              lblMessage.setText("Error during Edit. " + "Error: " + error.toString());
     public void stop()
          //Terminate the connection
          try
               if (conBook != null)
               conBook.close();
          catch(SQLException error)
               lblMessage.setText("Unable to disconnect");

How DO you compile then?
If you don't type "javac", you must be using an IDE.
In your IDE there should be some kind of configuration
tab or option for "compiler options" or compilation options
or compiler arguments... something like that.
put "-deprecation" in that text box and recompile.
Your compiler should tell you all about which methods
are deprecated -- you then go to your trust JavaDocs
and lookup those methods in the API and read WHY they
are deprecated (i.e. OLD, outdated, defunct, no longer used)
and what you should use instead. Then, correct your
code to no longer use the deprecated methods and instead
do things as suggested in the deprecation comments.

Similar Messages

  • Error: overrides a deprecated API

    Hi:
    I get the following error when I try to compile my code:
    Note: CalendarTest.java uses or overrides a deprecated API. Recompile with "-deprecation" for details.
    1 warning
    How do I solve the problem?
    Thanks.
    Describes a calendar for a set of appointments.
    @version 1.0
    import java.util.Vector;
    import java.util.*;
    public class CalendarTest
    {  public static void main(String[] args)
          Calendar markCalendar = new Calendar("Mark");
          Date start = new Date(2003 - 1900, 5 /*June*/, 2, 15, 0, 0);
          Date end = new Date(2003 - 1900, 5, 2, 16, 0, 0);
          markCalendar.addApp(new Appointment(start, end, "doctor"));
          markCalendar.print();     
    Describes a calendar for a set of appointments.
    class Calendar
       Constructs a calendar for the person named.
       public Calendar(String aName)
       {  name = aName;
          appointments = new Vector();
       Adds an appointment to this Calendar.
       @param anApp The appointment to add.
       public void addApp(Appointment anApp)
          appointments.add(anApp);
       Removes an appointment from this Calendar.
       @param anApp The appointment to be removed.
       public void removeApp(Appointment toFind)
          for ( int i = 0; i < appointments.size(); i++)
             if (((Appointment)appointments.get(i)).equals(toFind))
                 appointments.remove(i);
       Tests for duplicate appointment dates.
       public void dupsTest()
          for (int x = 0; x < appointments.size(); x++)
             Appointment check = (Appointment)appointments.get(x);
             for (int y = appointments.size()-1; y > x; y --)
                Appointment nextApp =(Appointment) appointments.get(y);
                if (check.match(nextApp))
                {  System.out.println("Duplicate appointments: ");
                   check.print();
                   nextApp.print();
       Prints the Calendar.
       public void print()
       {  System.out.println(name + "               C A L E N D A R");
          System.out.println();
           System.out.println("Date   Starttime    EndTime   Appointment");
          for (int i = 0; i < appointments.size(); i++)
          {  Appointment nextApp =(Appointment) appointments.get(i);
             nextApp.print();
       private Vector appointments;
       private String name;
       private Appointment theAppointment;
    Describes an appointment.
    class Appointment
       public Appointment(Date aStarttime,Date aEndtime, String aApp)
          starttime = aStarttime;
          endtime = aEndtime;  
          app = aApp;
    Method to test whether on object equals another.
    @param otherObject  The other object.
    @return true if equal, false if not
    public boolean equals(Object otherObject)
          if (otherObject instanceof Appointment)
          {  Appointment other = (Appointment)otherObject;
             return (date.equals(other.date) && starttime.equals(other.starttime)
                     && endtime.equals(other.endtime) && app.equals(other.app));
           else return false;
    Method to test whether part of an object equals another.
    @param otherObject  The other object.
    @return true if equal, false if not
    public boolean match(Object otherObject)
        if (otherObject instanceof Appointment)
         {  Appointment other = (Appointment)otherObject;
            return (date.equals(other.date) && starttime.equals(other.starttime)
                    && endtime.equals(other.endtime));
          else return false;
       Prints the Date, Starttime, Endtime and a description of the
       appointment.
       public void print()  
       {  System.out.println();
          System.out.println(date + "   " + starttime + "          " + endtime
              + "       " + app );
          System.out.println();
       private Date starttime;
       private Date endtime;
       private String app;

    The methods you used to instantiate your new dates has been deprecated and should no longer be used. This is just a warning though and your code will still work. Sun is just telling you that they no longer support those constructors for the Date class and that future releases of J2SE may not have them included in the API. If you wanted to, you could ignore it, or you could use the sample code instead for your Date creations:
    //need the following additional import
    import java.text.*;
    //HH is hours (0-23) see SimpleDateFormat for others
    DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    Date start= formatter.parse("06/02/2003 15:00:00");
    Date end = formatter.parse("06/02/2003 16:00:00");tajenkins

  • Having problems linking two java classes getting a "deprecated API" error??

    Hi,
    I am tryin to link one page to another in my program, however i get the followin msg:-
    Project\alphaSound.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    Process completed.
    this only happens when i add the bold piece of code to the class; even though the italic piece of code does take you to a new page?:-
    public class alphaSound extends JPanel implements ActionListener
    {static JFrame f = new JFrame("AlphaSound");
    public alphaSound() {
    public void actionPerformed(ActionEvent event) {
                 Object source = event.getSource();
    else if(source == vowel)
    { Vowelm vm = new Vowelm();
    vm.setSize(Toolkit.getDefaultToolkit().getScreenSize());
    vm.show();
    f.dispose();
    else if(source == back)
    { MainPage main = new MainPage();
    main.setSize(400,300);
    main.show();
    f.dispose();}
    public static void main(String s[]) {
            WindowListener l = new WindowAdapter() {
                public void windowClosing(WindowEvent e) {System.exit(0);}
            //JFrame f = new JFrame("AlphaSound");
            f.addWindowListener(l);
            f.getContentPane().add(new alphaSound());
            f.setSize(Toolkit.getDefaultToolkit().getScreenSize()); 
            f.show();
    }here is the class its tryin to call
    public class Vowelm extends JPanel implements ActionListener
    {static JFrame v = new JFrame("VowelSound");
       public Vowelm() {
                                                   ..etc...
    public static void main(String s[]) {
            WindowListener l = new WindowAdapter() {
                public void windowClosing(WindowEvent e) {System.exit(0);}
            //JFrame f = new JFrame("VowelSound");
            v.addWindowListener(l);
            v.getContentPane().add(new VowelmSound());
            v.setSize(Toolkit.getDefaultToolkit().getScreenSize()); 
            v.show();
    }Im pretty sure ther is some conflict between the two classes due to the way they are called and designed?
    Hope you can help!
    Kind Regards
    Raj

    You may want to check your show() calls and see if
    they can be replaced with setVisible(). Forexample,
    in your Vowelm code, you have a static JFrame v.
    At
    the end of your main function, you use v.show().As
    of JDK1.1, this has been deprecated in favour of
    setVisible(boolean).hey show() in JFrame is from Window and in windowits
    not deprecated ..
    show is not decrecated thats for sure ... i dontknow
    y you said that ...
    you can look in docs as well..
    True - but this in turn overrides show() from
    java.awt.Component, which has been deprecated. My
    guess is that's where the problem comes from.
    Thanks for the Dukes!
    FlicAnd then again - perhaps not. After looking into this a bit more, I take back my last comment about the Component override. However, as I said in my original reply, compiling with -deprecation should tell you which show() call is flagging the error. There is definitely one somewhere that the JVM doesn't like - without seeing your complete code, it's hard to say exactly where. Based on what you've posted, my guess is that it is within the Vowelm class.
    Next time, I'll try to avoid 'shooting from the hip'.
    Again, thanks for the Dukes,
    Flic

  • Java compile error for removed API

    Hi,
    What are the Java compile errors for API that has been removed?
    As I understand it, API elements are deprecated and not removed from the API immediately, but will be removed in future releases or after so many years.
    When Java code is compliled in a higher Java version, and the API has finally been removed - what are the errors that will be ouput in the log?
    Thank you for your time.

    WalterLaan wrote:
    And if you recompile one with a method removed that the other use and then run the other you would get a NoSuchMethodError (or more generally just an error sub class of LinkageError).
    Not that you should be catching those unless you accept classes from the user (as plugins).Presumably you mean he should not be catching them?
    @OP: In general, you should not catch unchecked exceptions. These are RuntimeException, Error, and their descendants. There are exceptions, such as at "layer boundaries," or when you don't want errors in one module/application/plugin/etc. to affect or prevent processing in others.

  • Deprecated API error??`

    hi!
    i m getting this error :
    Note: FileInputDemo.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    for the code:
    /* * * FileOutputDemo
    * * Demonstration of FileOutputStream and
    * PrintStream classes
    import java.io.*;
    class FileInputDemo {
    public static void main(String args[]) {
         if (args.length == 1) {
              try {
                   // Open the file that is the first
                   // command line parameter
                   FileInputStream fstream = new FileInputStream(args[0]);
                        // Convert our input stream to a
                        // DataInputStream
                        DataInputStream in = new DataInputStream(fstream);
                        // Continue to read lines while
                        // there are still some left to read
                        while (in.available() !=0) {
                             // Print file line to screen
                             System.out.println (in.readLine());
                        in.close();
                   catch (Exception e) {
                        System.err.println("File input error");
              else System.out.println("Invalid parameters");
    someone plz help me!!
    thanks
    :)

    i m getting this error :It is a "note" or warning, not an error.
    Note: FileInputDemo.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.Have you tried recompiling it with -Xlint:deprecation?

  • When i compile my program i get overrides a deprecated API.

    there is no error in the program but this message override a deprecated API and there is no execute. here is the program please help me.
    * Swing version.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.BorderFactory.*;
    import javax.swing.border.* ;
    public class ff extends JPanel implements ActionListener {
    JButton n5,n2,n7,b1,b2,b3,b4,b5,b6,b7,b8,b9;
    public ff(){
    boolean inAnApplet = true;
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new FlowLayout());
    //topPanel.setBackground(lightBlue);
    Border etchedBorder = BorderFactory.createEtchedBorder(Color.blue,Color.cyan);
    topPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,"Dog Products",
    TitledBorder.DEFAULT_JUSTIFICATION,
    TitledBorder.DEFAULT_POSITION,
    new Font("Serif",Font.BOLD,15),
    Color.black));
    Icon h5 = new ImageIcon( "c:\\a\\birdfood1t.gif" );
    n5 = new JButton("Button 1",h5);
    topPanel.add(n5);
    n5.setActionCommand("n5");
    n5.addActionListener(this);
    //getContentPane().add(topPanel,BorderLayout.NORTH);
    Icon h2 = new ImageIcon( "c:\\a\\birdfood1t.gif" );
    n2 = new JButton("Button 1",h2);
    topPanel.add(n2);
    n2.setActionCommand("n2");
    n2.addActionListener(this);
    //getContentPane().add(topPanel,BorderLayout.NORTH);
    Icon h7 = new ImageIcon( "c:\\a\\birdfood1t.gif" );
    n7 = new JButton("Button 2",h7);topPanel.add(n7);
    n7.setActionCommand("n7");
    n7.addActionListener(this);
    //getContentPane().add(topPanel,BorderLayout.NORTH);
    //birdfoodw();
    //public void birdfoodw() {
    //Container contentPane = getContentPane();
    JPanel v=new JPanel();
    v.setLayout(new BorderLayout());
    // setLayout(new BoxLayout(contentPane,
    JPanel v1=new JPanel();
    v1.setLayout(new GridLayout(9,1));
    v1.add(n5);
    v1.add(n2);
    v1.add(n7);
    JScrollPane sp=new JScrollPane(v1);
    v.add(sp);
    add(v,BorderLayout.CENTER);
    protected void buildToyList() {
    Icon x1 = new ImageIcon("c:\\a\\dogtoys1t.gif");
    b1.setIcon(x1);
    b1.setActionCommand("toys1");
    b1.setText("Dog toy #1");
    Icon x2 = new ImageIcon("c:\\a\\dogtoys2t.gif");
    b2.setIcon(x2);
    b2.setActionCommand("toys1");
    b2.setText("Dog toy #1");
    Icon x3 = new ImageIcon("c:\\a\\dogtoys3t.gif");
    b3.setIcon(x3);
    b3.setActionCommand("toys1");
    b3.setText("Dog toy #1");
    Icon x4 = new ImageIcon("c:\\a\\dogtoys4t.gif");
    b4.setIcon(x4);
    b4.setActionCommand("toys1");
    b4.setText("Dog toy #1");
    Icon x5 = new ImageIcon("c:\\a\\dogtoys5t.gif");
    b5.setIcon(x5);
    b5.setActionCommand("toys1");
    b5.setText("Dog toy #1");
    Icon x6 = new ImageIcon("c:\\a\\dogtoys6t.gif");
    b6.setIcon(x6);
    b6.setActionCommand("toys1");
    b6.setText("Dog toy #1");
    Icon x7 = new ImageIcon("c:\\a\\dogtoys7t.gif");
    b7.setIcon(x7);
    b7.setActionCommand("toys1");
    b7.setText("Dog toy #1");
    Icon x8 = new ImageIcon("c:\\a\\dogtoys1t.gif");
    b8.setIcon(x8);
    b8.setActionCommand("toys1");
    b8.setText("Dog toy #1");
    Icon x9 = new ImageIcon("c:\\a\\dogtoys1t.gif");
    b9.setIcon(x9);
    b9.setActionCommand("toys1");
    b9.setText("Dog toy #1");
    protected void buildFoodList() {
    Icon x1 = new ImageIcon("c:\\a\\dogfood1t.gif");
    b1.setIcon(x1);
    b1.setActionCommand("food1");
    b1.setText("Dog toy #1");
    Icon x2 = new ImageIcon("c:\\a\\dogfood2t.gif");
    b2.setIcon(x2);
    b2.setActionCommand("food1");
    b2.setText("Dog toy #1");
    Icon x3 = new ImageIcon("c:\\a\\dogfood3t.gif");
    b3.setIcon(x3);
    b3.setActionCommand("food1");
    b3.setText("Dog toy #1");
    Icon x4 = new ImageIcon("c:\\a\\dogfood4t.gif");
    b4.setIcon(x4);
    b4.setActionCommand("food1");
    b4.setText("Dog toy #1");
    Icon x5 = new ImageIcon("c:\\a\\dogfood5t.gif");
    b5.setIcon(x5);
    b5.setActionCommand("food1");
    b5.setText("Dog toy #1");
    Icon x6 = new ImageIcon("c:\\a\\dogfood6t.gif");
    b6.setIcon(x6);
    b6.setActionCommand("food1");
    b6.setText("Dog toy #1");
    Icon x7 = new ImageIcon("c:\\a\\dogfood7t.gif");
    b7.setIcon(x7);
    b7.setActionCommand("food1");
    b7.setText("Dog toy #1");
    Icon x8 = new ImageIcon("c:\\a\\dogfood1t.gif");
    b8.setIcon(x8);
    b8.setActionCommand("food1");
    b8.setText("Dog toy #1");
    Icon x9 = new ImageIcon("c:\\a\\dogfood1t.gif");
    b9.setIcon(x9);
    b9.setActionCommand("food1");
    b9.setText("Dog toy #1");
    protected void buildTreatList() {
    Icon x1 = new ImageIcon("c:\\a\\dogtreats1t.gif");
    b1.setIcon(x1);
    b1.setActionCommand("treats1");
    b1.setText("Dog toy #1");
    Icon x2 = new ImageIcon("c:\\a\\dogtreats2t.gif");
    b2.setIcon(x2);
    b2.setActionCommand("treats1");
    b2.setText("Dog toy #1");
    Icon x3 = new ImageIcon("c:\\a\\dogtreats3t.gif");
    b3.setIcon(x3);
    b3.setActionCommand("treats1");
    b3.setText("Dog toy #1");
    Icon x4 = new ImageIcon("c:\\a\\dogtreats4t.gif");
    b4.setIcon(x4);
    b4.setActionCommand("treats1");
    b4.setText("Dog toy #1");
    Icon x5 = new ImageIcon("c:\\a\\dogtreats5t.gif");
    b5.setIcon(x5);
    b5.setActionCommand("treats1");
    b5.setText("Dog toy #1");
    Icon x6 = new ImageIcon("c:\\a\\dogtreats6t.gif");
    b6.setIcon(x6);
    b6.setActionCommand("treats1");
    b6.setText("Dog toy #1");
    Icon x7 = new ImageIcon("c:\\a\\dogtreats7t.gif");
    b7.setIcon(x7);
    b7.setActionCommand("treats1");
    b7.setText("Dog toy #1");
    Icon x8 = new ImageIcon("c:\\a\\dogtreats1t.gif");
    b8.setIcon(x8);
    b8.setActionCommand("treats1");
    b8.setText("Dog toy #1");
    Icon x9 = new ImageIcon("c:\\a\\dogtreats1t.gif");
    b9.setIcon(x9);
    b9.setActionCommand("treats1");
    b9.setText("Dog toy #1");
    public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand() == "n5")
    buildFoodList();
    else if (e.getActionCommand() == "n7")
    buildToyList();
    else if (e.getActionCommand() == "n2")
    buildTreatList();
    public static void main(String args[]) {
    ff window = new ff();
    //window.inAnApplet = false;
    //window.setTitle("bird food");
    window.setSize(123,233);
    window.show();
    window.setVisible(true);

    Sana,
    Look at your last but one line where you have used ".show()", which is a deprecated API. Change to ".repaint()" and try it out.
    window.setSize(123,233);
    window.show(); // show() is deprecated API...
    window.setVisible(true);Cool
    Ravi

  • Show error overrides a deprecated API ?

    hi,
    when my java program run, it shows,
    Note: D:\javaexample\myJavaPgm.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    what this error message.
    Can I ignore this warning ?.
    or how can i solve this warning?.

    hi,
    when my java program run, it shows,
    Note: D:\javaexample\myJavaPgm.java uses or overrides
    a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    what this error message.
    Can I ignore this warning ?.
    or how can i solve this warning?.Deprecation means a method or class has been identified as obsolete. That means that there is a newer and better alternative to something you are doing. It also means that perhaps one day the deprecated thing will disappear from the API (unlikely probably but could happen).
    To solve the warning you will have to find out what it's complaining about.
    javac -deprecation myJavaPgm.javaWill tell you what exactly is the problem.
    Then you can look in the API for alternatives.

  • Fetch Document from workspace+java API+ObjectByPath.java compile error

    Hi All,
    (Hyo version: 11.1.1.3)
    I was trying to export files imported into workspace. For testing purpose I imported P4S.pdf in 'Sample Content' folder.
    While looking for various options I came across Java API for workspace.(See samples in C:\Hyperion\products\Foundation\workspace\SDK\samples\java)
    I found a Java sample named "ObjectByPath.java". I complied (using JC.bat) and executed (with Execapi.bat) and came with this output:
    C:\Hyperion\products\Foundation\workspace\SDK\bin>execapi ObjectByPath admin password localhost 6800 "Sample Content/P4S.pdf"
    library not available, add it to your classpath: spf.jar
    Path : Sample Content/P4S.pdf
    Name : P4S.pdf
    Path : /Sample Content/P4S.pdf
    Mime Type: application/pdf
    Class : com.sqribe.rm.DataObjectImpl
    ObjectID : 0000013828cfc4b7-0000-a30d-7f000001
    Unfortunately the object could not be exported. I checked the "ObjectByPath.java" file and I saw:
    String path = args[4];
    RMBase tObject = rep.getObjectByPath(path);
    // tObject.toXML(System.out);
    System.out.println("Path : " + path);
    if (tObject instanceof BaseObject) {
    BaseObject baseObj = (BaseObject) tObject;
    System.out.println("Name : " + baseObj.getName());
    System.out.println("Path : " + baseObj.getPath());
    System.out.println("Mime Type: " + baseObj.getObjectType().getMimeType());
    System.out.println( "Class : " + tObject.getClass().getName());
    System.out.println( "ObjectID : " + tObject.getObjectID());
    Note that the exported line is commented.
    When I remove the comment and recomplile with JC.bat I get this error:
    C:\Hyperion\products\Foundation\workspace\SDK\bin>jc ObjectByPath.java
    ObjectByPath.java:32: unreported exception java.io.IOException; must be caught or declared to be thrown
    tObject.toXML(System.out);
    ^
    Note: ObjectByPath.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    1 error
    Any idea how to resolve this issue.
    Thanks,
    Ankit

    It says to add spf.jar to your classpath. Can you do a search on the file system for that file? If you find it add to your classpath.
    By commenting that line out you just produced another, unrelated error.
    Thanks
    Nick

  • Force use of deprecated API to fail compilation

    Ok, short question that I hope you can help me with. Is it possible to force the compilation to fail if I a deprecated API is used. Why? Well, we are a large number of developers and sometimes people use a method or class that has been deprecated because they are either lazy or can't find the new class/method.

    This isn't possible with the default compiler. You would have to write a special compiler wrapper that calls the java compiler (sun.tools.javac.Main in tools.jar)
    Can't you just hang a rubber chicken over the desk of the person who checked in bad code - that was what happened at my last job :)
    Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.
    Sure they're new - come get them started!

  • Java Compilation error.

    Trying to compile java file and got following error. Java version I am using is 1.4.2. I tried to comple same with
    -source 1.3 option also but not luck. Any help would be appriciated.
    DataBrokerClass.java:963: cannot resolve symbol
    symbol : method getArray (java.util.Map)
    location: class oracle.sql.ARRAY
    Object[] AdvoIntCfgHhcRecObj = (Object[]) advointCfgHhcRecArrOut.getArray(map);
    ^
    Note: DataBrokerClass.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    1 error

    it has nothing to do with the java version or java itself really, you are trying to call a method that does not exist. I am not the worst person on earth, so I did some investigating on the net. It turns out that you are incorrectly using a Map, you want to use a Hashtable in stead.
    Just for reference, what I did to investigate is, I typed "oracle.sql.ARRAY" into google and that gave me the javadocs for this class.

  • JCo (in UDF) throws: "...uses or overrides a deprecated API."

    Hi everybody,
    when using JCO in UDF I get the error:
    <b>MyMapping_.java uses or overrides a deprecated API. Note: Recompile with -deprecation for details. 1 error</b>
    Does anybody know how to solve the problem?
    The problem occurs only when I try to access the tableParameters:
    <i> codes =     function.getTableParameterList().getTable("COMPANYCODE_LIST");</i>
    Regards Mario

    Hi Mario,
    With every latest Java version its APIs keep changing and some functions are removed or "deprecated", so if you are getting this error which means JRE you are using not have that function available so compile your code with Java -deprecation to suppress that error.
    To check JRE version type Java - version on command prompt and then refer to Java API (also available online) to get detail about that particular function, otherwise you can also chose alternate function to achieve your programming objecting. I prefer if you see JCO API for help on this function.
    Refer to sample code : http://www.sapdevelopment.co.uk/java/jco/jco_callfunc.htm
    Regards,
    Gourav

  • Note: ImageViewer.java uses or overrides a deprecated API.

    hi,
    iam gettin this error after compilation
    Note: ImageViewer.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    & am running it on j2sdk1.5.0
    Plzzz help

    waoh man......but what 2 look....
    heres da code...
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.swing.*;
    public class ImageViewer
    public static void main(String[] args)
    JFrame frame = new ImageViewerFrame();
    frame.setTitle("ImageViewer");
    frame.setSize(300, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.show();
    class ImageViewerFrame extends JFrame
    public ImageViewerFrame()
    // set up menu bar
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    JMenu menu = new JMenu("File");
    menuBar.add(menu);
    JMenuItem openItem = new JMenuItem("Open");
    menu.add(openItem);
    openItem.addActionListener(new FileOpenListener());
    JMenuItem exitItem = new JMenuItem("Exit");
    menu.add(exitItem);
    exitItem.addActionListener(new
    ActionListener()
    public void actionPerformed(ActionEvent event)
    System.exit(0);
    // use a label to display the images
    label = new JLabel();
    Container contentPane = getContentPane();
    contentPane.add(label, "Center");
    private class FileOpenListener implements ActionListener
    public void actionPerformed(ActionEvent evt)
    // set up file chooser
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("."));
    // accept all files ending with .gif
    chooser.setFileFilter(new
    javax.swing.filechooser.FileFilter()
    public boolean accept(File f)
    return f.getName().toLowerCase()
    .endsWith(".gif")
    || f.isDirectory();
    public String getDescription()
    return "GIF Images";
    // show file chooser dialog
    int r = chooser.showOpenDialog(ImageViewerFrame.this);
    // if image file accepted, set it as icon of the label
    if(r == JFileChooser.APPROVE_OPTION)
    String name
    = chooser.getSelectedFile().getPath();
    label.setIcon(new ImageIcon(name));
    private JLabel label;
    }

  • What's this mean? - "uses or overrides a deprecated API."

    Hi, I'm a newbie at Java and I'm getting this error when I try to compile my program:
    "Note: C:\MarsLander\NewUser.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details."
    I haven't a clue what is going on here, can anybody help?

    Methods and classes may get deprecated with the threat that they will be removed form the API in a future version. Deprecated things can be but should not be used.
    (Deprecated features can be undeprecated in a future version though. There are at least tow examples for this.)
    As the message tells, compile it with the -deprecation flag and the compiler will report which method or class it is about.

  • Code overrides deprecated API...recompile with

    Hi,
    Need help compiling SampleProgram(see code below).
    (using JDK 1.3.1_06. and JCreator 2.5 build 8)
    The following code(see below) compiles with an error:
    "Note: C:\Documents and Settings\Alex1\My
    Documents\Alex Files\My Java\Lesson
    2\SampleProgram.java uses or overrides a deprecated
    API.
    Note: Recompile with -deprecation for details.
    Process completed."
    How can I change to make it work? Please help/advise.
    Alex
    CODE below:
    import java.awt.*;
    import javax.swing.*;
    public class SampleProgram
    static JFrame f1;
    static JPanel p1;
    JButton b1, b2;
    SampleProgram()
         p1 = new JPanel();
         b1 = new JButton("Submit");
         b2 = new JButton();
    b2.setLabel("Cancel");
    p1.add(b1);
    p1.add(b2);
    public static void main(String args[])
         f1 = new JFrame("Sample Application");
         f1.getContentPane().add(p1);
         f1.setSize(300,300);

    Compile the progam this way to show u where the deprecation is.
    javac -deprecation SampleProgram.java
    This show that button.setLabel("Cancel");
    has been deprecated.
    Why don't you do it just the way you set the label for the submit button.
    That's like;
    b2 = new JButton("Cancel");
    By the way programs runs fine with the deprecation, its not an error.

  • Java re-compilation error!!!!

    Hi All,
    I had got a set of .class files from a software provider.
    When i tried to run a command it used to give an error.
    I tried to contact that vendor but in vain.....
    So i decided to decompile the class files to get the reason for error.
    I took 1 class file which i was getting as error. I extracted all the .java files, in that class file. Now when i try to recompile them i'm getting an error
    symbol not declared!!!!!!
    And i checked in the source file. The variables are not declared in the file. How did it compile before??? Why it is not compiling now. Please help me out. I'm very new to java.
    Thanking you,
    Venki

    [email protected] wrote:
    Note: DataBrokerClass.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details. Pardon me for asking a silly question, but did you compile with the "-deprecation" option?
    If yes, what was the command output?
    The error message you wrote that you are getting: "cannot resolve symbol", usually indicates that the relevant Oracle JDBC driver was not included in the classpath of the compiler command.
    Which JDBC driver are you using?
    How are you compiling this class?
    From the command line, using "javac"?
    From some IDE?
    I assume that "advointCfgHhcRecArrOut" is an instance of "oracle.sql.ARRAY"?
    Please verify.
    Good Luck,
    Avi.

Maybe you are looking for

  • K9N Platinum, 4GB of RAM, XP shows 3.25GB

    I have a K9N Platinum with 4 sticks of 1024MB Corsair.  On POST it detects full 4096MB of memory.  CPU-Z also shows 4GB. However, in XP, right-click My Computer, properties, it shows 3.25GB of RAM. Now, I did some googling and the solution to this se

  • Java class on jsp

    how can we call a java class on click of submit button in jsp page?

  • Best way to handle Sprite animation

    Hi all, Comments on overheads (memory/performance) on the following techniques? These are overly simplified, but you get the idea? Bitmap.visible // Assume we have a bunch of sprites already in memory as bitmap data var spriteData : Vector.<BitmapDat

  • Why is the FM tuner disabled on my Galaxy S5 phone?

    Why is the FM tuner on my Galaxy S5 phone disabled? Can this be fixed? What's wrong with this phone?

  • Javascript not working?

    I have a little SearchPage javascript on one of my web pages. It doesn't work in Lion 10.7.3. It worked in my previous OS (10.4.11) in all browsers. Anyone know how to fix this? Thanks. (Yes, I've got everything enabled in Safari/Firefox/Chrome prefe