Help in resolving symbol

Hi everyone , im new to java but im working hard at it, i am doing a a java applet and i have assigned buttons , comboboxes etc, but when i go to compile its sayin it cant resolve the symbol. I hve 26 errors and this is one of them........im inserting a piece of the code error comment
any assistance to reslove will be appreciated.
RepairJobs.java:212:cannot resolve symbol
symbol : class ActionListener
location: class RepairJobs
new ActionListener()

Looking at what he posted, it looks like he is creating an anonymous inner class. If you know your java compiler errors, then you would know that the error that he is getting indicates that the compiler cannot find a class named ActionListener in any of the packages that have been imported (whether implicitly or explicitly). Implementing an interface that the compiler doesn't know about will do nothing to solve his problem.

Similar Messages

  • Very URGENT: PLS HELP:canno resolve symbol session.setAttrribute

    hi everbody,
    i'm new at this and have got a presentation after 1 day!....pls help
    when i compile the servlet i get :
    cannot resolve symbol
    metod: setAttribute (java.lang.String,java.lang.String)
    location: interface(javax.servlet.http.HttpSession)
    the servlet that gets te error when comiled is:
    * Authenticate.java
    // this places all user variables in session
    //to access use session.getAttribute
    //dispatcher stuff
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    * @author Gudiya
    * @version
    public class Authenticate extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    HttpSession session = request.getSession(true);
    Connection con=null;
    String sessionid;
    String deptcode;
    String desig;
    String add1;
    String add2;
    String contname;
    PrintWriter out = response.getWriter();
    try
    response.setContentType("text/html");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:SACFA","","");
    System.out.println("connection established");
    catch(ClassNotFoundException e){
    System.out.println("database driver not found");
    System.out.println(e.toString());
    catch(Exception e){System.out.println(e.toString());
    // ServletContext context=getServletContext();
    String username=request.getParameter("username");
    String password=request.getParameter("password");
    try{
    PreparedStatement stmt=con.prepareStatement("SELECT * FROM AUTHENTICATION,mb_add where AUTHENTICATION.NAME=? AND AUTHENTICATION.PASSWORD=? AND mb_add.DEPT_NAME=?");
    stmt.setString(1,username);
    stmt.setString(2,password);
    stmt.setString(3,username);
    ResultSet rs=stmt.executeQuery();
    boolean rowfound=false;
    rowfound=rs.next();
    if (rowfound==true)
    sessionid=session.getId();
    System.out.println(sessionid);
    //context.setAttribute("userid",sessionid);
    // session.setAttribute("user",username);
    rs.beforeFirst();
    while (rs.next())
    deptcode=rs.getString("DEPT_CODE");
    desig=rs.getString("DESIGNATION");
    add1=rs.getString("ADDRESS1");
    add2=rs.getString("ADDRESS2");
    contname=rs.getString("NAME");
    session.setAttribute("dept_code",deptcode);
    session.setAttribute("designation",desig);
    session.setAttribute("address1",add1);
    session.setAttribute("address2",add2);
    session.setAttribute("cont_name",contname);
    //context.getRequestDispatcher(request.getParameter("dispatcho")).forward(request,response);
    }          out.println("<html>");
              out.println("<head>");
              out.println("<title>Successful Login Screen</title>");
              out.println("</head>");
              out.println("<body bgcolor='ORANGE'>");
    out.println("<script language='Javascript'>");
    out.println("<!--function send_onclick(mydispatcho) {var dispatcho;if(mydispatcho=='Noc'){ dispatcho='/Noc1';}if(mydispatcho=='Ce'){ dispatcho='/Ce1';} if(mydispatcho=='Bye'){ dispatcho='/Bye1';}}-->");
    out.println("</script>");
    out.println("WELCOME MEMBERS FROM "+ username);
    //print decorative html statements here
              out.println(" SELECT NY ONE ACTION:-");
    out.println("<form Action="+"\"servlet/noc\""+" method =post>");//call for your noc servlet
    //print decorative html statements here
    out.println("<INPUT TYPE=submit VALUE='GENERATE NOC' NAME='NOC' language='javascript'>");
    out.println("</form>");
    //print decorative html statements here
    out.println("<form Action="+"\"servlet/comments\""+" method =post>");//call for your comment servlet
    out.println("<INPUT TYPE=submit VALUE='ENTER/ MODIFY COMMENTS' NAME='COMMENTS' language='javascript' >");
    out.println("</form>");
    //print decorative html statements here
    out.println("<form Action="+"\"servlet/bye\""+" method = post>");
    out.println("<INPUT TYPE=submit VALUE=EXIT NAME=EXIT language='javascript' >"); //place javascript fucction for exiting window
    out.println("</form>");
              out.println("</body>");
              out.println("</html>");
    con.close();
    } catch( SQLException e){ }
    out.close();}
    NOTE: I'M USING JDK1.3 and jsdk2.0
    pls help me....
    Thank u all,
    ashna

    HTTP Status 404 - /mywork/servlet/Authenticate
    hi dheeraj,
    thank u so much the servlet comiled!!!
    now i have a new problem....the Tomcat server cannot find its class file. i have placed the class file in C:\Program Files\Apache Group\Tomcat 4.1\webapps\mywork\WEB-INF\classes.
    the error it shows is as follows:
    type Status report
    message /mywork/servlet/Authenticate
    description The requested resource (/mywork/servlet/Authenticate) is not available.
    Apache Tomcat/4.1.18-LE-jdk14
    PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11

  • PLEASE HELP: cannot resolve symbol class

    it's showing me the error on the following lines 7 and 9
    it says cannot resolve symbol class Name and cannot resolve symbol class Phone
    I also have a package name addressBook and it contains two files Entry.java and Address.java
    Here is the code:
    import java.io.*;
    import addressBook.*;
    public class AddressDr
         public static void main(String[] args)throws IOException
              Name name;
              Address address;
              Phone phone;
              Entry entry;
              String first, last, middle, street, city, state, zip;
              int areaCode, number;
              BufferedReader in;
              in=new BufferedReader(new InputStreamReader(System.in));
              PrintWriter outFile;
              outFile=new PrintWriter(new FileWriter("Entries"));
              System.out.println("Quit entered fot the first name ends the " + "application.");
              System.out.print("Enter first name: ");
              first=in.readLine();
              while (first.compareTo("Quit") !=0)
                   System.out.print("Enter last name: ");
                   last=in.readLine();
                   System.out.print("Enter middle name: ");
                   middle=in.readLine();
                   name=new Name(first, last, middle);
                   System.out.print("Enter street address: ");
                   street=in.readLine();
                   System.out.print("Enter city: ");
                   city=in.readLine();
                   System.out.print("Enter state: ");
                   state=in.readLine();
                   System.out.print("Enter ZIP code: ");
                   zip=in.readLine();
                   address=new Address(street, city, state, zip);
                   System.out.print("Enter areaCode: ");
                   areaCode = Integer.parseInt(in.readLine());
                   System.out.print("Enter number: ");
                   number=Integer.parseInt(in.readLine());
                   phone=new Phone(areaCode, number);
                   entry= new Entry(name, address, phone);
                   entry.writeToFile(outFile);
                   System.out.print("Enter first name: ");
                   first=in.readLine();
              outFile.close();
    }

    OK. Here is how I did it.
    I have AddressDr which is Address driver.
    I have two files Address and Entry which in package addressBook.
    AddressDr:
    import java.io.*;
    import addressBook.*;
    public class AddressDr
         public static void main(String[] args)throws IOException
              Name name;
              Address address;
              Phone phone;
              Entry entry;
              String first, last, middle, street, city, state, zip;
              int areaCode, number;
              BufferedReader in;
              in=new BufferedReader(new InputStreamReader(System.in));
              PrintWriter outFile;
              outFile=new PrintWriter(new FileWriter("Entries"));
              System.out.println("Quit entered fot the first name ends the " + "application.");
              System.out.print("Enter first name: ");
              first=in.readLine();
              while (first.compareTo("Quit") !=0)
                   System.out.print("Enter last name: ");
                   last=in.readLine();
                   System.out.print("Enter middle name: ");
                   middle=in.readLine();
                   name=new Name(first, last, middle);
                   System.out.print("Enter street address: ");
                   street=in.readLine();
                   System.out.print("Enter city: ");
                   city=in.readLine();
                   System.out.print("Enter state: ");
                   state=in.readLine();
                   System.out.print("Enter ZIP code: ");
                   zip=in.readLine();
                   address=new Address(street, city, state, zip);
                   System.out.print("Enter areaCode: ");
                   areaCode = Integer.parseInt(in.readLine());
                   System.out.print("Enter number: ");
                   number=Integer.parseInt(in.readLine());
                   phone=new Phone(areaCode, number);
                   entry= new Entry(name, address, phone);
                   entry.writeToFile(outFile);
                   System.out.print("Enter first name: ");
                   first=in.readLine();
              outFile.close();
    Entry:
    package addressBook;
    import java.io.*;
    public class Entry
         Name name;
         Address address;
         Phone phone;
    public Entry(Name newName, Address newAddress, Phone phoneNumber)
         name = newName;
         address = newAddress;
         phone = phoneNumber;
    public Name knowName()
         return name;
    public Address knowAddress()
         return address;
    public Phone knowPhone()
         return phone;
    public void writeToFile(PrintWriter outFile)
         outFile.println(name.knowFirstName());
         outFile.println(name.knowLastName());
         outFile.println(name.knowMiddleName());
         oufFile.println(address.knowStreet());
         outFile.println(address.knowState());
         outFile.println(address.knowCity());
         outFile.println(address.knowZip());
         outFile.println(phone.knowAreaCode());
         outFile.println(phone.knowDigits());
    Address:
    package addressBook;
    public class Address
         String street;
         String city;
         String state;
         String zipCode;
         public Address(String newStreet, String newCity, String newState, String zip)
              street=newStreet;
              city=newCity;
              state=newState;
              zipCode=zip;
         public String knowStreet()
              return street;
         public String knowCity()
              return city;
         public String knowState()
              return state;
         public String knowZip()
              return zipCode;
    }

  • "cannot resolve symbol" in a Timer !!!Please Help!!!

    I am doing a program for a class which involves timers. I am using JCreator and when i try to construct a new timer, the compiler points to the "new" in the line:
    Timer T1=new Timer(interval, ActionListener);
    ^
    This is what it looks like and the error reads: cannot resolve symbol; constructor Timer.
    please tell me if yiou have any information or suggestions as to how this error might be remedied.

    Sure, here it is:
    import java.awt.event.*;
    import javax.swing.Timer;
    import javax.swing.JOptionPane;
    import java.util.*;
    interface ActionListener
         void actionPerformed(ActionEvent event);     
    class Ploid
         public static void main(String[] args)
              class Car implements ActionListener
                   int mpg=30;
                   int mph=35;
                   int gtank=20;
                   int interval;
                   int changer;
                   int totalmiles;
                   Car(int x)
                        interval=x;
                   public void actionPerformed(ActionEvent event)
                        for(int c=0;c<(interval/1000);c++)
                             totalmiles=totalmiles+mph;
                        int hyt=mpg*gtank;
                        if(totalmiles>hyt)
                             int y=totalmiles-hyt;
                             totalmiles=totalmiles-y;
                             System.out.println(totalmiles);
                        else
                             System.out.println(totalmiles);
    class SUV implements ActionListener
         int mpg=15;
         int mph=55;
         int gtank=30;
         int interval;
         int changer;
         int totalmiles;
         SUV(int x)
              interval=x;
              public void actionPerformed(ActionEvent event)
                   for(int c=0;c<(interval/1000);c++)
                        totalmiles=totalmiles+mph;
                   int hyt=mpg*gtank;
                   if(totalmiles>hyt)
                        int y=totalmiles-hyt;
                        totalmiles=totalmiles-y;
                        System.out.println(totalmiles);
                   else
                        System.out.println(totalmiles);
    class Semi implements ActionListener
         int mpg=60;
         int mph=80;
         int gtank=50;
         int interval;
         int changer;
         int totalmiles;
         Semi(int x)
              interval=x;
         public void actionPerformed(ActionEvent event)
              for(int c=0;c<(interval/1000);c++)
                   totalmiles=totalmiles+mph;
              int hyt=mpg*gtank;
              if(totalmiles>hyt)
                   int y=totalmiles-hyt;
                   totalmiles=totalmiles-y;
                   System.out.println(totalmiles);
              else
                   System.out.println(totalmiles);
              String flag="y";
              String trav=JOptionPane.showInputDialog("How long do you want to drive?(1000=1 hour)");
              int t1=Integer.parseInt(trav);
              Car listen=new Car(t1);
              SUV listener2=new SUV(t1);
              Semi listener3=new Semi(t1);
              final int t2=t1/1000;
              final int t3=t1/t2;
              ActionListener listener=null;
              Timer T1=new Timer(t3, listener);
              Timer T2=new Timer(t3, listener);
              Timer T3=new Timer(t3, listener);
              while(flag.equals("y"))
                   T1.start();
                   T2.start();
                   T3.start();
                   String g=JOptionPane.showInputDialog("Do you want to drive again?");
                   if((g.equals("y"))||(g.equals("Y")))
                        System.out.println("Let's Drive!");
                   else
                        flag=g;
                   System.exit(0);
    }Here is the errors:
    [errors]
    A:\Ploid2.java:116: cannot resolve symbol
    symbol : constructor Timer (int,ActionListener)
    location: class javax.swing.Timer
              Timer T1=new Timer(t3, listener);
    ^
    A:\Ploid2.java:117: cannot resolve symbol
    symbol : constructor Timer (int,ActionListener)
    location: class javax.swing.Timer
              Timer T2=new Timer(t3, listener);
    ^
    A:\Ploid2.java:118: cannot resolve symbol
    symbol : constructor Timer (int,ActionListener)
    location: class javax.swing.Timer
              Timer T3=new Timer(t3, listener);
    ^
    3 errors
    Process completed.
    [errors]
    ****There is the source code and the errors the compiler returns. That should be more help.****

  • HELP PLEASE Cannot resolve symbol error

    Only just started to atempt simple java programs and this same error keeps appearing. code i am using is:
    import java.io.*;
    class Q1
         public static void main(String[] args) throws IOException
              int num1,num2,sum;
              /*program statements start here*/
         System.out.printIn ("Input a number");
                   num1= Course_io.readInt();
              System.out.printIn ("Input another number");
                   num2= Course_io.readInt();
                   sum= num2 - num1;
              System.out.printIn ("Total is" +sum );
    and this is the error message i keep getting:
    javac -d . -g "C:\Java Programs\Q1.java"
    C:\Java Programs\Q1.java:12: cannot resolve symbol
    symbol : method printIn (java.lang.String)
    location: class java.io.PrintStream
    System.out.printIn ("Input a number");
    ^
    C:\Java Programs\Q1.java:16: cannot resolve symbol
    symbol : method printIn (java.lang.String)
    location: class java.io.PrintStream
    System.out.printIn ("Input another number");
    ^
    C:\Java Programs\Q1.java:22: cannot resolve symbol
    symbol : method printIn (java.lang.String)
    location: class java.io.PrintStream
    System.out.printIn ("Total is" +sum );
    ^
    3 errors
    Please help me, Thankyou.

    sum= num2 - num1;
    System.out.printIn ("Total is" +sum );While you're at it, do something about this, it's misleading.
    kind regards,
    Jos

  • Need help - method call error cannot resolve symbol

    My code compiles fine but I continue to receive a method call error "cannot resolve symbol - variable superman" - can't figure out why. Here is my code:
    public static String caesar(String message, int shift)
    {   [b]String result = "";
    for(int i = 0; i < message.length(); ++i)
    {   [b]char newChar = message.charAt(i + shift);
    result += newChar;
    return result.toUpperCase();
    I entered "superman" for message and "3" for the shift. Can someone please help? Thanks!

    Your post worked great - especially since it made me realize I was going about it all wrong! I was attempting to convert "superman" to "vxshupdq" - basically a cipher shift starting at index 0 and shifting it 3 character values which would result in s changing to v. I restructured my code:
    public static String caesar(String message, int shift)
    {   [b]String result = "";
    for(int i = 0; i < message.length(); ++i)
    {   [b]char newChar = message.charAt(i);
    result += (newChar + shift) % message.length();
    return result.toUpperCase();
    But it's displaying the result as a "60305041". How can I get it to display the actual characters?

  • Help!!! error: cannot resolve symbol

    can anyone tell me how to solve the following problem
    thank you
    cannot resolve symbol
    symbol : method decode (java.lang.String)
    location: class java.lang.Short
    Short psmShort = Short.decode(psmString);
    ^
    Long bdAddrLong = Long.decode("0x" + bdAddrString);
    ^

    that is because these methods does not exist. What you can use instead is parseShort(String) or parseLong.
    Maybe reading the javadoc could help you next time ;-)
    hth
    Kay

  • Illegal start of expression and cannot resolve symbol HELP

    Can someone pls help me?
    These are the two problems:
    --------------------Configuration: j2sdk1.4.1_02 <Default>--------------------
    C:\Documents and Settings\Laila\My Documents\CMT2080\Coursework\Game\Mindboggler.java:291: illegal start of expression
    public void inputJButtonActionPerformed( ActionEvent event )
    ^
    C:\Documents and Settings\Laila\My Documents\CMT2080\Coursework\Game\Mindboggler.java:285: cannot resolve symbol
    symbol: method inputJButtonActionPerformed (java.awt.event.ActionEvent)
                   inputJButtonActionPerformed( event);
    Here is my code :
    //Mind boggler quiz
    //Marcelyn Samson
    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.lang.*;
    public class Mindboggler extends JFrame
              // JPanel for welcome window
              private JPanel welcomeJPanel;
              private JPanel presetJPanel;
         private JLabel titleJLabel;
         private JLabel quizJLabel;
         private JLabel girlJLabel, headJLabel;
         private JLabel introJLabel;
         private JButton startJButton;
         // JPanel for questionone window
         private JPanel questiononeJPanel;
         private JLabel textJLabel;
         private JPanel becksJPanel;
         private JButton oneJButton, twoJButton, threeJButton, fourJButton, nextJButton;
              //JPanel for questiontwo window
              private JPanel questiontwoJPanel;
              private JPanel orlandoJPanel;
              private JLabel q2JLabel;
              private JCheckBox lordJCheckBox;
              private JCheckBox faceJCheckBox;
              private JCheckBox piratesJCheckBox;
              private JButton next2JButton;
         private JButton inputJButton;
         //JPanel for questionthree
         private JPanel questionthreeJPanel;
         private JPanel howmuchJPanel;
         private JLabel howmuchJLabel;
         private JLabel nameJLabel;
         private JTextField nameJTextField;
         private JLabel moneyJLabel;
         private JTextField moneyJTextField;
         private JButton next3JButton;
         //Publics
         public JPanel welcomeJFrame, questionJFrame, questiontwoJFrame, questionthreeJFrame;
         //contentPane
              public Container contentPane;
              //no argument constructor
              public Mindboggler()
                   createUserInterface();
              //create and position components
              private void createUserInterface()/////////////////////////; semo colon do not edit copy paste
                   //get contentPane and set layout to null
                   contentPane = getContentPane();
                   contentPane.setLayout ( null );
                   welcome();
                   //set properties of applications window
                   setTitle( "Mindboggler" ); // set JFrame's title bar string
              setSize( 600, 400 ); // set width and height of JFrame
              setVisible( true ); // display JFrame on screen
              } // end method createUserInterface
              public void welcome(){
                        // set up welcomeJPanel
                   welcomeJPanel = new JPanel();
                   welcomeJPanel.setLayout( null );
                   welcomeJPanel.setBounds(0, 0, 600, 400);
                   welcomeJPanel.setBackground( Color.GREEN );
                   // set up textJLabel
                   titleJLabel = new JLabel();
                   titleJLabel.setText( "Mind Boggler" );
                   titleJLabel.setLocation( 30, 10);
                   titleJLabel.setSize( 550, 70);
                   titleJLabel.setFont( new Font( "SansSerif", Font.PLAIN, 30 ) );
                   titleJLabel.setHorizontalAlignment( JLabel.CENTER );
                   welcomeJPanel.add( titleJLabel );
                   // set up presetJPanel
                   presetJPanel = new JPanel();
                   presetJPanel.setLayout( null );
                   presetJPanel.setBounds( 150, 10, 300, 80 );
                   presetJPanel.setBackground( Color.GRAY );
                   welcomeJPanel.add( presetJPanel );
                   //setup Intro JLabel
                   introJLabel = new JLabel();
                   introJLabel.setText( "Think, think, think. Can you get all the questions right?" );
                   introJLabel.setBounds( 40, 100, 500, 200 );
                   introJLabel.setFont( new Font( "SansSerif", Font.PLAIN, 18 ) );
                   introJLabel.setHorizontalAlignment( JLabel.CENTER );
                   welcomeJPanel.add(introJLabel);
                   //set up head JLabel
                   headJLabel = new JLabel();
                   headJLabel.setIcon( new ImageIcon( "head.jpeg") );
                   headJLabel.setBounds( 540, 5, 40, 160 );
                   headJLabel.setHorizontalAlignment( JLabel.CENTER );
                   welcomeJPanel.add(headJLabel);
                        //setup girlJLabel
                   girlJLabel = new JLabel();
                   girlJLabel.setIcon( new ImageIcon( "girl.Jjpeg") );
                   girlJLabel.setBounds( 5, 10, 60, 100 );
                   girlJLabel.setHorizontalAlignment( JLabel.CENTER );
                   welcomeJPanel.add(girlJLabel);
                        //set up startJbutton
                   startJButton = new JButton();
                   startJButton.setText( "Start" );
                   startJButton.setBounds(250, 300, 100, 30);
                   startJButton.setFont( new Font( "SansSerif", Font.BOLD, 14) );
                   welcomeJPanel.add(startJButton);
                   contentPane.add(welcomeJPanel);
                   startJButton.addActionListener(
                        new ActionListener(){
                             public void actionPerformed(ActionEvent e){
                                  question();
              public void question()
                   //set up question one JPanel
                   welcomeJPanel.setVisible(false);
                   questiononeJPanel = new JPanel();
         questiononeJPanel.setLayout( null );
              questiononeJPanel.setBounds(0, 0, 600,400);
              questiononeJPanel.setBackground( Color.GREEN );
              // set up textJLabel
              textJLabel = new JLabel();
              textJLabel.setText( "Who did Beckham supposedly cheat with?" );
              textJLabel.setLocation( 20, 20);
              textJLabel.setSize( 550, 70);
              textJLabel.setFont( new Font( "SansSerif", Font.BOLD, 20 ) );
              textJLabel.setHorizontalAlignment( JLabel.CENTER );
              questiononeJPanel.add( textJLabel );
                   // set up presetJPanel
              becksJPanel = new JPanel();
              becksJPanel.setLayout( null );
              becksJPanel.setBorder( new TitledBorder(
         "Question 1" ) );
              becksJPanel.setBounds( 10, 10, 570, 80 );
              becksJPanel.setBackground( Color.GRAY );
              questiononeJPanel.add( becksJPanel );
                   // set up oneJButton
              oneJButton = new JButton();
              oneJButton.setBounds( 10, 120, 300, 40 );
              oneJButton.setText( "Britney Spears" );
              oneJButton.setBackground( Color.ORANGE );
              questiononeJPanel.add( oneJButton );
              // set up twoJButton
              twoJButton = new JButton();
              twoJButton.setBounds( 10, 180, 300, 40 );
              twoJButton.setText( "Meg Ryan" );
              twoJButton.setBackground( Color.ORANGE );
              questiononeJPanel.add( twoJButton );
              // set up threeJButton
              threeJButton = new JButton();
              threeJButton.setBounds( 10, 240, 300, 40 );
              threeJButton.setText( "Rebecca Loos" );
              threeJButton.setBackground( Color.ORANGE );
              questiononeJPanel.add( threeJButton );
              // set up fourJButton
              fourJButton = new JButton();
              fourJButton.setBounds( 10, 300, 300, 40 );
              fourJButton.setText( "Angelina Jolie" );
              fourJButton.setBackground( Color.ORANGE );
              questiononeJPanel.add( fourJButton );
                   // set up nextJButton
                   nextJButton = new JButton();
                   nextJButton.setBounds ( 375, 300, 150, 40 );
                   nextJButton.setText("Next");
                   nextJButton.setBackground( Color.GRAY );
                   questiononeJPanel.add( nextJButton );
                   contentPane.add(questiononeJPanel);
              nextJButton.addActionListener(
                        new ActionListener(){
                             public void actionPerformed(ActionEvent e){
                                  questiontwo();
              public void questiontwo()
                   //set up question two JPanel
                   questiononeJPanel.setVisible(false);
                   questiontwoJPanel=new JPanel();
                   questiontwoJPanel.setLayout(null);
                   questiontwoJPanel.setBounds(0, 0, 600, 400);
                   questiontwoJPanel.setBackground( Color.GREEN );
                   // set up q2JLabel
              q2JLabel = new JLabel();
              q2JLabel.setBounds( 20, 20, 550, 70 );
              q2JLabel.setText( "What films has Orlando Bloom starred in?" );
              q2JLabel.setFont(new Font( "SansSerif", Font.BOLD, 20 ) );
         q2JLabel.setHorizontalAlignment( JLabel.CENTER );
    questiontwoJPanel.add(q2JLabel);
    //set up orlandoJPanel
    orlandoJPanel = new JPanel();
    orlandoJPanel.setLayout(null);
    orlandoJPanel.setBorder( new TitledBorder("Question 2"));
    orlandoJPanel.setBounds( 10, 10, 570, 80);
    orlandoJPanel.setBackground(Color.GRAY);
    questiontwoJPanel.add(orlandoJPanel);
    // set up lordJCheckBox
              lordJCheckBox = new JCheckBox();
              lordJCheckBox.setBounds( 16, 112, 200, 24 );
              lordJCheckBox.setText( "1. Lord of The Rings" );
              questiontwoJPanel.add( lordJCheckBox );
                   // set up faceJCheckBox
              faceJCheckBox = new JCheckBox();
              faceJCheckBox.setBounds( 16, 159, 200, 24 );
              faceJCheckBox.setText( "2. Face Off" );
              questiontwoJPanel.add( faceJCheckBox );
              // set up piratesJCheckBox
              piratesJCheckBox = new JCheckBox();
              piratesJCheckBox.setBounds( 16, 206, 200, 24 );
              piratesJCheckBox.setText( "3. Pirates of The Caribean" );
              questiontwoJPanel.add( piratesJCheckBox );
              // set up inputJButton
              inputJButton = new JButton();
              inputJButton.setBounds(20, 256, 200, 21 );
              inputJButton.setText( "Input answer" );
              questiontwoJPanel.add( inputJButton );
    inputJButton.addActionListener(
         new ActionListener()
              //event handler called when user clicks inputJButton
              public void actionPerformed( ActionEvent event )
                   inputJButtonActionPerformed( event);
    //show JOptionMessages when user clicks on JCheckBoxes and inputJButton
    public void inputJButtonActionPerformed( ActionEvent event )
         //display error message if no JCheckBoxes is checked
         if ( ( !lordJCheckBox.isSelected() && !faceJCheckBox.isSelected() && !piratesJCheckBox.isSelected() ) )
              //display error message
              JOptionPane.showMessageDialog( null, "Please check two boxes", JOptionPane.ERROR_MESSAGE );
         // if lordjcheckbox and pirates is selected = right
         else
              if ( ( lordJCheckBox.isSelected() && piratesJCheckBox.isSelected() ))
                   JOptionPane.showMessageDialog(null, "Thats RIGHT!");
              //if others are selected = wrong
              else
                   if ( (lordJCheckBox.isSelected() && faceJCheckBox.isSelected() ))
                        JOptionPane.showMessageDialog(null, "Thats WRONG");
                   else
                        ( (faceJCheckBox.isSelected() && piratesJCheckBox.isSelected() ))
                             JOptionPane.showMessageDialog(null, "Thats WRONG");
    // set up nest2JButton
              next2JButton = new JButton();
              next2JButton.setBounds( 155, 296, 94, 24 );
              next2JButton.setText( "Next" );
              questiontwoJPanel.add( next2JButton );
    contentPane.add(questiontwoJPanel);
    next2JButton.addActionListener(
         new ActionListener(){
              public void actionPerformed(ActionEvent e){
                   questionthree();
    } // end questiontwo
    public void questionthree()
         //setup questionthree JPanel
         questiontwoJPanel.setVisible(false);
         questionthreeJPanel = new JPanel();
         questionthreeJPanel.setLayout(null);
         questionthreeJPanel.setBounds(0, 0, 600, 400);
         questionthreeJPanel.setBackground( Color.GREEN);
              // main method
              public static void main( String[] args )
              Mindboggler application = new Mindboggler();
              application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              } // end method main
    }// end class
    WOULD BE VERY GEATFUL

    Just want to say thank you by the way for trying to help. Ive moved public void inputJButtonActionPerformed( ActionEvent event ) outside of brackets. Now i have a different problem on it. Sorry about this.
    PROBLEM: --------------------Configuration: <Default>--------------------
    C:\Documents and Settings\Laila\My Documents\CMT2080\Coursework\Game\Mindboggler.java:353: 'else' without 'if'
    else ( ( !lordJCheckBox.isSelected() && !faceJCheckBox.isSelected && !piratesJCheckBox.isSelected() ) )
    ^
    1 error
    Process completed.
    MY CODE:
    //Mind boggler quiz
    //Marcelyn Samson
    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.lang.*;
    public class Mindboggler extends JFrame
              // JPanel for welcome window
              private JPanel welcomeJPanel;
              private JPanel presetJPanel;
         private JLabel titleJLabel;
         private JLabel quizJLabel;
         private JLabel girlJLabel, headJLabel;
         private JLabel introJLabel;
         private JButton startJButton;
         // JPanel for questionone window
         private JPanel questiononeJPanel;
         private JLabel textJLabel;
         private JPanel becksJPanel;
         private JButton oneJButton, twoJButton, threeJButton, fourJButton, nextJButton;
              //JPanel for questiontwo window
              private JPanel questiontwoJPanel;
              private JPanel orlandoJPanel;
              private JLabel q2JLabel;
              private JCheckBox lordJCheckBox;
              private JCheckBox faceJCheckBox;
              private JCheckBox piratesJCheckBox;
              private JButton next2JButton;
         private JButton inputJButton;
         //JPanel for questionthree
         private JPanel questionthreeJPanel;
         private JPanel howmuchJPanel;
         private JLabel howmuchJLabel;
         private JLabel nameJLabel;
         private JTextField nameJTextField;
         private JLabel moneyJLabel;
         private JTextField moneyJTextField;
         private JButton next3JButton;
         //Publics
         public JPanel welcomeJFrame, questionJFrame, questiontwoJFrame, questionthreeJFrame;
         //contentPane
              public Container contentPane;
              //no argument constructor
              public Mindboggler()
                   createUserInterface();
              //create and position components
              private void createUserInterface()/////////////////////////; semo colon do not edit copy paste
                   //get contentPane and set layout to null
                   contentPane = getContentPane();
                   contentPane.setLayout ( null );
                   welcome();
                   //set properties of applications window
                   setTitle( "Mindboggler" ); // set JFrame's title bar string
              setSize( 600, 400 ); // set width and height of JFrame
              setVisible( true ); // display JFrame on screen
              } // end method createUserInterface
              public void welcome(){
                        // set up welcomeJPanel
                   welcomeJPanel = new JPanel();
                   welcomeJPanel.setLayout( null );
                   welcomeJPanel.setBounds(0, 0, 600, 400);
                   welcomeJPanel.setBackground( Color.GREEN );
                   // set up textJLabel
                   titleJLabel = new JLabel();
                   titleJLabel.setText( "Mind Boggler" );
                   titleJLabel.setLocation( 30, 10);
                   titleJLabel.setSize( 550, 70);
                   titleJLabel.setFont( new Font( "SansSerif", Font.PLAIN, 30 ) );
                   titleJLabel.setHorizontalAlignment( JLabel.CENTER );
                   welcomeJPanel.add( titleJLabel );
                   // set up presetJPanel
                   presetJPanel = new JPanel();
                   presetJPanel.setLayout( null );
                   presetJPanel.setBounds( 150, 10, 300, 80 );
                   presetJPanel.setBackground( Color.GRAY );
                   welcomeJPanel.add( presetJPanel );
                   //setup Intro JLabel
                   introJLabel = new JLabel();
                   introJLabel.setText( "Think, think, think. Can you get all the questions right?" );
                   introJLabel.setBounds( 40, 100, 500, 200 );
                   introJLabel.setFont( new Font( "SansSerif", Font.PLAIN, 18 ) );
                   introJLabel.setHorizontalAlignment( JLabel.CENTER );
                   welcomeJPanel.add(introJLabel);
                   //set up head JLabel
                   headJLabel = new JLabel();
                   headJLabel.setIcon( new ImageIcon( "head.jpeg") );
                   headJLabel.setBounds( 540, 5, 40, 160 );
                   headJLabel.setHorizontalAlignment( JLabel.CENTER );
                   welcomeJPanel.add(headJLabel);
                        //setup girlJLabel
                   girlJLabel = new JLabel();
                   girlJLabel.setIcon( new ImageIcon( "girl.Jjpeg") );
                   girlJLabel.setBounds( 5, 10, 60, 100 );
                   girlJLabel.setHorizontalAlignment( JLabel.CENTER );
                   welcomeJPanel.add(girlJLabel);
                        //set up startJbutton
                   startJButton = new JButton();
                   startJButton.setText( "Start" );
                   startJButton.setBounds(250, 300, 100, 30);
                   startJButton.setFont( new Font( "SansSerif", Font.BOLD, 14) );
                   welcomeJPanel.add(startJButton);
                   contentPane.add(welcomeJPanel);
                   startJButton.addActionListener(
                        new ActionListener(){
                             public void actionPerformed(ActionEvent e){
                                  question();
              public void question()
                   //set up question one JPanel
                   welcomeJPanel.setVisible(false);
                   questiononeJPanel = new JPanel();
         questiononeJPanel.setLayout( null );
              questiononeJPanel.setBounds(0, 0, 600,400);
              questiononeJPanel.setBackground( Color.GREEN );
              // set up textJLabel
              textJLabel = new JLabel();
              textJLabel.setText( "Who did Beckham supposedly cheat with?" );
              textJLabel.setLocation( 20, 20);
              textJLabel.setSize( 550, 70);
              textJLabel.setFont( new Font( "SansSerif", Font.BOLD, 20 ) );
              textJLabel.setHorizontalAlignment( JLabel.CENTER );
              questiononeJPanel.add( textJLabel );
                   // set up presetJPanel
              becksJPanel = new JPanel();
              becksJPanel.setLayout( null );
              becksJPanel.setBorder( new TitledBorder(
         "Question 1" ) );
              becksJPanel.setBounds( 10, 10, 570, 80 );
              becksJPanel.setBackground( Color.GRAY );
              questiononeJPanel.add( becksJPanel );
                   // set up oneJButton
              oneJButton = new JButton();
              oneJButton.setBounds( 10, 120, 300, 40 );
              oneJButton.setText( "Britney Spears" );
              oneJButton.setBackground( Color.ORANGE );
              questiononeJPanel.add( oneJButton );
              // set up twoJButton
              twoJButton = new JButton();
              twoJButton.setBounds( 10, 180, 300, 40 );
              twoJButton.setText( "Meg Ryan" );
              twoJButton.setBackground( Color.ORANGE );
              questiononeJPanel.add( twoJButton );
              // set up threeJButton
              threeJButton = new JButton();
              threeJButton.setBounds( 10, 240, 300, 40 );
              threeJButton.setText( "Rebecca Loos" );
              threeJButton.setBackground( Color.ORANGE );
              questiononeJPanel.add( threeJButton );
              // set up fourJButton
              fourJButton = new JButton();
              fourJButton.setBounds( 10, 300, 300, 40 );
              fourJButton.setText( "Angelina Jolie" );
              fourJButton.setBackground( Color.ORANGE );
              questiononeJPanel.add( fourJButton );
                   // set up nextJButton
                   nextJButton = new JButton();
                   nextJButton.setBounds ( 375, 300, 150, 40 );
                   nextJButton.setText("Next");
                   nextJButton.setBackground( Color.GRAY );
                   questiononeJPanel.add( nextJButton );
                   contentPane.add(questiononeJPanel);
              nextJButton.addActionListener(
                        new ActionListener(){
                             public void actionPerformed(ActionEvent e){
                                  questiontwo();
              public void questiontwo()
                   //set up question two JPanel
                   questiononeJPanel.setVisible(false);
                   questiontwoJPanel=new JPanel();
                   questiontwoJPanel.setLayout(null);
                   questiontwoJPanel.setBounds(0, 0, 600, 400);
                   questiontwoJPanel.setBackground( Color.GREEN );
                   // set up q2JLabel
              q2JLabel = new JLabel();
              q2JLabel.setBounds( 20, 20, 550, 70 );
              q2JLabel.setText( "What films has Orlando Bloom starred in?" );
              q2JLabel.setFont(new Font( "SansSerif", Font.BOLD, 20 ) );
         q2JLabel.setHorizontalAlignment( JLabel.CENTER );
    questiontwoJPanel.add(q2JLabel);
    //set up orlandoJPanel
    orlandoJPanel = new JPanel();
    orlandoJPanel.setLayout(null);
    orlandoJPanel.setBorder( new TitledBorder("Question 2"));
    orlandoJPanel.setBounds( 10, 10, 570, 80);
    orlandoJPanel.setBackground(Color.GRAY);
    questiontwoJPanel.add(orlandoJPanel);
    // set up lordJCheckBox
              lordJCheckBox = new JCheckBox();
              lordJCheckBox.setBounds( 16, 112, 200, 24 );
              lordJCheckBox.setText( "1. Lord of The Rings" );
              questiontwoJPanel.add( lordJCheckBox );
                   // set up faceJCheckBox
              faceJCheckBox = new JCheckBox();
              faceJCheckBox.setBounds( 16, 159, 200, 24 );
              faceJCheckBox.setText( "2. Face Off" );
              questiontwoJPanel.add( faceJCheckBox );
              // set up piratesJCheckBox
              piratesJCheckBox = new JCheckBox();
              piratesJCheckBox.setBounds( 16, 206, 200, 24 );
              piratesJCheckBox.setText( "3. Pirates of The Caribean" );
              questiontwoJPanel.add( piratesJCheckBox );
              // set up inputJButton
              inputJButton = new JButton();
              inputJButton.setBounds(20, 256, 200, 21 );
              inputJButton.setText( "Input answer" );
              questiontwoJPanel.add( inputJButton );
    inputJButton.addActionListener(
         new ActionListener()
              //event handler called when user clicks inputJButton
              public void actionPerformed( ActionEvent event )
                   inputJButtonActionPerformed( event);
    // set up nest2JButton
              next2JButton = new JButton();
              next2JButton.setBounds( 155, 296, 94, 24 );
              next2JButton.setText( "Next" );
              questiontwoJPanel.add( next2JButton );
    contentPane.add(questiontwoJPanel);
    next2JButton.addActionListener(
         new ActionListener(){
              public void actionPerformed(ActionEvent e){
                   questionthree();
    } // end questiontwo
    public void questionthree()
         //setup questionthree JPanel
         questiontwoJPanel.setVisible(false);
         questionthreeJPanel = new JPanel();
         questionthreeJPanel.setLayout(null);
         questionthreeJPanel.setBounds(0, 0, 600, 400);
         questionthreeJPanel.setBackground( Color.GREEN);
         //setup howmuchJLabel
         howmuchJLabel = new JLabel();
         howmuchJLabel.setText("I'm a student and would be very greatful if you could donate some money as it would help me very much.");
         howmuchJLabel.setBounds(20, 20, 550, 70);
         howmuchJLabel.setFont(new Font("SansSerif",Font.BOLD,14));
         howmuchJLabel.setHorizontalAlignment(JLabel.CENTER);
         questionthreeJPanel.add(howmuchJLabel);
         //setup howmuchJPanel
         howmuchJPanel = new JPanel();
         howmuchJPanel.setLayout(null);
         howmuchJPanel.setBorder( new TitledBorder("Question 3"));
         howmuchJPanel.setBounds(10, 10, 570, 80);
         howmuchJPanel.setBackground( Color.GRAY);
         questionthreeJPanel.add(howmuchJPanel);
         //setup nameJLabel
         nameJLabel = new JLabel();
         nameJLabel.setText("Name");
         nameJLabel.setBounds(10, 160, 150, 24);
         nameJLabel.setFont(new Font("SansSerif",Font.BOLD,12));
         questionthreeJPanel.add(nameJLabel);
         //setup nameJTextField
         nameJTextField = new JTextField();
         nameJTextField.setBounds(125, 160, 200, 24 );
         questionthreeJPanel.add(nameJTextField);
         contentPane.add(questionthreeJPanel);
         //show JOptionMessages when user clicks on JCheckBoxes and inputJButton
    public void inputJButtonActionPerformed( ActionEvent event )
         //display error message if no JCheckBoxes is checked
         else ( ( !lordJCheckBox.isSelected() && !faceJCheckBox.isSelected && !piratesJCheckBox.isSelected() ) )
              //display error message
              JOptionPane.showMessageDialog( null, "Please check two boxes", JOptionPane.ERROR_MESSAGE );
         // if lordjcheckbox and pirates is selected = right
         else
              if ( ( lordJCheckBox.isSelected() && piratesJCheckBox.isSelected() ))
                   JOptionPane.showMessageDialog(null, "Thats RIGHT!");
              //if others are selected = wrong
              else
                   if ( (lordJCheckBox.isSelected() && faceJCheckBox.isSelected() ))
                        JOptionPane.showMessageDialog(null, "Thats WRONG");
                   else
                        ( (faceJCheckBox.isSelected() && piratesJCheckBox.isSelected() ))
                             JOptionPane.showMessageDialog(null, "Thats WRONG");
              // main method
              public static void main( String[] args )
              Mindboggler application = new Mindboggler();
              application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              } // end method main
    }// end class

  • Help.. incompatiable type and cannot resolve symbol error...

    I have this class Box
    class Box{
         private int width;
           private int height;
           private int depth;
           private int BoxCounter;
         public void click()
         BoxCounter = 0;
    }and in my main code, I'm calling it via
    private Box arrBox[];All this goes fine until I try to place code in to make array empty upon a selected action by
    if (color == blue) {arrBox = new Box();}Here I'm getting the error saying that its an incompatible type... it says I have Box but it requires class Box[]...(the ^ pointing at the word "new")
    also, I have this
    public void button()
    arrBox.click()
    }This returns the unable to resolve symbol error (the ^ points at the dot).... I tried changing things around but the problem persists, can someone point out where I hv gone wrong?
    Many thanks

    private Box arrBox[];The line above does not create an array, it only declares that the variable arrBox can refernce an array of type Box. Arrays are objects just like Box - you need a new Box[10], for example, to create the array.
    if (color == blue) {arrBox = new Box();}
    Here I'm getting the error saying that its an
    incompatible type... it says I have Box but it
    requires class Box[]...(the ^ pointing at the word
    "new")As previously stated, arrBox is a reference to an array of Box, not an object instance of Box.
    A lot of your trouble can be resolved by understanding how arrays work in java. Try here.
    http://java.sun.com/docs/books/tutorial/java/data/arrays.html
    You must create an array similar to creating any object. Next, you must create objects to go inside the array. It's difficult without knowing the rest of your code, but here goes.
    private Box[] arrBox = new Box[10];
    for(int index=0;index<arrBox.length;index++)  {
       int color = getColor(index); //I'm making this up
       if(color == blue) arrBox[index] = new Box();
    }The above code will create a new Box for any index where the color is blue. The indices where the color isn't blue are equal to null.

  • "cannot resolve symbol" help..

    Here is a very short and simpel program that won't compile after I reinstalled java on my computer.
    import java.lang.Math.*;
    import java.awt.*;
    public class PiTest extends Frame {
         public static void main(String[] p){
         System.out.println("testing MATHs");
         System.out.println(""+sin(10));
    I get the following error:
    PiTest.java:8: cannot resolve symbol
    symbol : method sin (int)
    location: class PiTest
    System.out.println(""+sin(10));
    ^
    [total 1553ms]
    1 error
    Why doesn't the compiler recognise the sine function? I have set my classpath to c:\j2sdk1.4.1_01\lib.
    I don't know what I'm doing wrong...

    Replace sin(10) with Math.sin(10), it should work.
    import java.lang.Math.*;
    import java.awt.*;
    public class PiTest extends Frame {
    public static void main(String[] p){
    System.out.println("testing MATHs");
    //System.out.println(""+sin(10));
    System.out.println(""+Math.sin(10));

  • "cannot resolve symbol" error...please help

    when itry to compile my program i get the error " cannot resolve
    symbol" variable setLayout.
    My program is very small. Can someone tell me why i keep
    getting error?
    thanx
    trin.
    import java.applet.*;
    import java.awt.*;
    public class MyProg extends Applet
         Button btnOne = new Button("One");
         Button btnTwo = new Button("Two");
         public void init()
              Panel pOne = new Panel( ) ;
              pOne.setLayout = ( new GridLayout( ));
              pOne.add(btnOne);
              pOne.add(btnTwo);
              add(pOne);

    Change:
    pOne.setLayout = ( new GridLayout( ));to
    pOne.setLayout( new GridLayout());It's a method call, not an assignment :)

  • Getting error message Cannot Resolve Symbol when trying to compile a class

    Hello All -
    I am getting an error message cannot resolve symbol while trying to compile a java class that calls another java class in the same package. The called class compiles fine, but the calling class generates
    the following error message:
    D:\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes\cal>javac
    ConnectionPool.java
    ConnectionPool.java:158: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    private void addConnection(PooledConnection value) {
    ^
    ConnectionPool.java:144: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    PooledConnection pcon = new PooledConnection(con);
    ^
    ConnectionPool.java:144: cannot resolve symbol
    symbol : class PooledConnection
    location: class cal.ConnectionPool
    PooledConnection pcon = new PooledConnection(con);
    The code is listed as follows for PooledConnection.java (it compiles fine)
    package cal;
    import java.sql.*;
    public class PooledConnection {
    // Real JDBC Connection
    private Connection connection = null;
    // boolean flag used to determine if connection is in use
    private boolean inuse = false;
    // Constructor that takes the passed in JDBC Connection
    // and stores it in the connection attribute.
    public PooledConnection(Connection value) {
    if ( value != null ) {
    connection = value;
    // Returns a reference to the JDBC Connection
    public Connection getConnection() {
    // get the JDBC Connection
    return connection;
    // Set the status of the PooledConnection.
    public void setInUse(boolean value) {
    inuse = value;
    // Returns the current status of the PooledConnection.
    public boolean inUse() {
    return inuse;
    // Close the real JDBC Connection
    public void close() {
    try {
    connection.close();
    catch (SQLException sqle) {
    System.err.println(sqle.getMessage());
    Now the code for ConnectionPool.java class that gives the cannot
    resolve symbol error
    package cal;
    import java.sql.*;
    import java.util.*;
    public class ConnectionPool {
    // JDBC Driver Name
    private String driver = null;
    // URL of database
    private String url = null;
    // Initial number of connections.
    private int size = 0;
    // Username
    private String username = new String("");
    // Password
    private String password = new String("");
    // Vector of JDBC Connections
    private Vector pool = null;
    public ConnectionPool() {
    // Set the value of the JDBC Driver
    public void setDriver(String value) {
    if ( value != null ) {
    driver = value;
    // Get the value of the JDBC Driver
    public String getDriver() {
    return driver;
    // Set the URL Pointing to the Datasource
    public void setURL(String value ) {
    if ( value != null ) {
    url = value;
    // Get the URL Pointing to the Datasource
    public String getURL() {
    return url;
    // Set the initial number of connections
    public void setSize(int value) {
    if ( value > 1 ) {
    size = value;
    // Get the initial number of connections
    public int getSize() {
    return size;
    // Set the username
    public void setUsername(String value) {
    if ( value != null ) {
    username = value;
    // Get the username
    public String getUserName() {
    return username;
    // Set the password
    public void setPassword(String value) {
    if ( value != null ) {
    password = value;
    // Get the password
    public String getPassword() {
    return password;
    // Creates and returns a connection
    private Connection createConnection() throws Exception {
    Connection con = null;
    // Create a Connection
    con = DriverManager.getConnection(url,
    username, password);
    return con;
    // Initialize the pool
    public synchronized void initializePool() throws Exception {
    // Check our initial values
    if ( driver == null ) {
    throw new Exception("No Driver Name Specified!");
    if ( url == null ) {
    throw new Exception("No URL Specified!");
    if ( size < 1 ) {
    throw new Exception("Pool size is less than 1!");
    // Create the Connections
    try {
    // Load the Driver class file
    Class.forName(driver);
    // Create Connections based on the size member
    for ( int x = 0; x < size; x++ ) {
    Connection con = createConnection();
    if ( con != null ) {
    // Create a PooledConnection to encapsulate the
    // real JDBC Connection
    PooledConnection pcon = new PooledConnection(con);
    // Add the Connection to the pool.
    addConnection(pcon);
    catch (Exception e) {
    System.err.println(e.getMessage());
    throw new Exception(e.getMessage());
    // Adds the PooledConnection to the pool
    private void addConnection(PooledConnection value) {
    // If the pool is null, create a new vector
    // with the initial size of "size"
    if ( pool == null ) {
    pool = new Vector(size);
    // Add the PooledConnection Object to the vector
    pool.addElement(value);
    public synchronized void releaseConnection(Connection con) {
    // find the PooledConnection Object
    for ( int x = 0; x < pool.size(); x++ ) {
    PooledConnection pcon =
    (PooledConnection)pool.elementAt(x);
    // Check for correct Connection
    if ( pcon.getConnection() == con ) {
    System.err.println("Releasing Connection " + x);
    // Set its inuse attribute to false, which
    // releases it for use
    pcon.setInUse(false);
    break;
    // Find an available connection
    public synchronized Connection getConnection()
    throws Exception {
    PooledConnection pcon = null;
    // find a connection not in use
    for ( int x = 0; x < pool.size(); x++ ) {
    pcon = (PooledConnection)pool.elementAt(x);
    // Check to see if the Connection is in use
    if ( pcon.inUse() == false ) {
    // Mark it as in use
    pcon.setInUse(true);
    // return the JDBC Connection stored in the
    // PooledConnection object
    return pcon.getConnection();
    // Could not find a free connection,
    // create and add a new one
    try {
    // Create a new JDBC Connection
    Connection con = createConnection();
    // Create a new PooledConnection, passing it the JDBC
    // Connection
    pcon = new PooledConnection(con);
    // Mark the connection as in use
    pcon.setInUse(true);
    // Add the new PooledConnection object to the pool
    pool.addElement(pcon);
    catch (Exception e) {
    System.err.println(e.getMessage());
    throw new Exception(e.getMessage());
    // return the new Connection
    return pcon.getConnection();
    // When shutting down the pool, you need to first empty it.
    public synchronized void emptyPool() {
    // Iterate over the entire pool closing the
    // JDBC Connections.
    for ( int x = 0; x < pool.size(); x++ ) {
    System.err.println("Closing JDBC Connection " + x);
    PooledConnection pcon =
    (PooledConnection)pool.elementAt(x);
    // If the PooledConnection is not in use, close it
    if ( pcon.inUse() == false ) {
    pcon.close();
    else {
    // If it is still in use, sleep for 30 seconds and
    // force close.
    try {
    java.lang.Thread.sleep(30000);
    pcon.close();
    catch (InterruptedException ie) {
    System.err.println(ie.getMessage());
    I am using Sun JDK Version 1.3.0_02" and Apache/Tomcat 4.0. Both the calling and the called class are in the same directory.
    Any help would be greatly appreciated.
    tnx..
    addi

    Is ConnectionPool in this "cal" package as well as PooledConnection? From the directory you are compiling from it appears that it is. If it is, then you are compiling it incorrectly. To compile ConnectionPool (and PooledConnection similarly), you must change the current directory to the one that contains cal and type
    javac cal/ConnectionPool.

  • Cannot resolve symbol: class EJBObject

    Using javac I get this compile error on this file Calculator.java
    Calculator.java:1: cannot resolve symbol
    symbol : class EJBObject
    location: package ejb
    import javax.ejb.EJBObject;
    ^
    Calculator.java:5: cannot resolve symbol
    symbol : class EJBObject
    location: interface Calculator
    public interface Calculator extends EJBObject {
    Source code for Calculator.java
    import javax.ejb.EJBObject;
    import java.rmi.*;
    public interface Calculator extends EJBObject {
         public long add (int x, int y) throws RemoteException;
         public long subtract (int x, int y) throws RemoteException;

    This code is from a book, so I will assume its a classpath problem. My
    classpath looks like:
    "C\QTJava.zip".;%J2EE_HOME%\lib\j2ee.jar;%J2EE_HOME%\lib\locale
    Also the following enviorment varibales have been set to:
    J2EE_HOME
    C:\Development\Java\j2sdkee1.3.1
    JAVA_HOME
    C:\Development\Java\jdk1.3.1
    Path
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;%JAVA_HOME%\bin;%J2EE_HOME%\bin
    I can run j2EE, like "j2EE -verbose" (no problems)
    also run cloudscape, like "cloudscape -start" (no problems)
    also can run deploytool, like "deploytool" (no problems, & deploy sample ear files from cd book)
    Your help is appreicated.

  • Cannot resolve symbol : class odbc ERROR

    Hi Helper
    I am trying to compile a the following and I am getting the error
    C:\jdk\websiter>javac MainServlet.java
    MainServlet.java:86: cannot resolve symbol
    symbol : class odbc
    location: package jdbc
    Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    * This is the servlet to send the user the names of all the sites present in the database
    public class MainServlet extends HttpServlet implements ServletConstants
    Connection m_con;
    PreparedStatement m_pstmt;
    ResultSet m_res;
    Vector m_vecsiteName;
    public void Init(ServletConfig config) throws ServletException {
         super.init(config);
    }// end of init()
    public void service(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
              m_vecsiteName = new Vector();
         try {
         Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
    m_con = DriverManager.getConnection("jdbc:odbc:sitewd", "", "");
    How can i fix it? thanks
    VT

    Replace the Statement
    Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
    as
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

  • Import java.util.Formatter - cannot resolve symbol

    I use j2sdk1.4.2_04
    when I try to compile my program using Formatter, it response error "cannot resolve symbol"
    Pls help!

    Where did you get this java.util.Formatter from? If you check the official 1.4.2 API for Java, that class does not exisit! However, java.util.logging.Formatter, does exisit...
    http://java.sun.com/j2se/1.4.2/docs/api/
    If you ment: java.util.logging.Formatter have you checked the API to make sure you are using it correctly???
    HTH.

Maybe you are looking for

  • PSE 12 does not close properly

    Hi, I just upgraded to PSE 12. When I run editor, after I exit the program, I cannot restart it again until I use windows task manager to end process of photoshopelementseditor.exe file. This seems to be a known problem. Any fixes out there? Windows

  • Photo Stream not in sync between iOS devices...

    This may not actually be a technical issue - it may be the way that it's designed. But if it is, then it seems pretty flawed. I own an iPad, iPhone, Apple TV and Macbook Pro. Photo Stream pictures are not in sync - ie: I deleted several from my Apple

  • Use of variables in connection pools

    Are there any other reasons to use variables in Connection Pool definitions other than if there are multiple CPs using a single DB ? I'm reading various articles about migration between environments (eg http://obieeblog.wordpress.com/2009/08/04/simpl

  • Question Re video and Ipad +apple tv

    I rented a SD video from Itunes videos this weekend. I downloaded to Ipad2 and wanted to project through apple TV as I have doen many many times. The sound came through, and the video showed the progress bar and icon of the movie but no visual, why i

  • Reading in 2 files

    Hi I want to know how i can read in 2 files that are both delimeterd by a comma and store them both in two diffrent arraylists. so that later on i can compare the two arraylist. thanks clare