Cannot resolve symbol on char variable

my compiler stops at this line
char variablename = keyboardInputChar();
i am trying to input a character and declare a variable at the same time.
what am i doing wrong?
any help appreciated.

my compiler stops at this line
char variablename = keyboardInputChar();Well, variable 'variablename' can definitely be resolved, because your defining it there; I think your compiler can't find method 'keyboardInputChar()' anywhere. Have you defined that method in the same class?
kind regards

Similar Messages

  • I am getting an error cannot resolve symbol variable?

    I am trying to run a PdfFormGenerator.java file and am using the iText API, hence have included
    the iText.jar file. When I compile the code I keep getting the following two errors:
    cannot resolve symbol variable CLASS_LOCATION
    cannot resolve symbol variable FORM_LOCATION
    can anyone guide me what I may have done wrong.
    Thanks,
    Zub

    Hi! To be more specific its these to line of the code is were I am going the errors:
        private String classLocation = Constants.CLASS_LOCATION;
        private String formLocation = Constants.FORM_LOCATION;Thanks

  • 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?

  • Class error - cannot resolve symbol "MyDocumentListener"

    Hello,
    this is a groaner I'm sure, but I don't see the problem.
    Newbie-itis probably ...
    I'm not concerned with what the class does, but it would be nice for the silly thing to compile!
    What the heck am I missing for "MyDocumentListener" ?
    C:\divelog>javac -classpath C:\ CenterPanel.java
    CenterPanel.java:53: cannot resolve symbol
    symbol : class MyDocumentListener
    location: class divelog.CenterPanel
    MyDocumentListener myDocumentListener = new MyDocumentListener(); // define the listener class
    ^
    CenterPanel.java:53: cannot resolve symbol
    symbol : class MyDocumentListener
    location: class divelog.CenterPanel
    MyDocumentListener myDocumentListener = new MyDocumentListener(); // define the listener class
    ^
    2 errors
    package divelog;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.lang.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.filechooser.*;
    import javax.swing.text.*;
    public class CenterPanel extends JPanel implements ActionListener
    { // Opens class
    static private final String newline = "\n";
    private JTextArea comments;
    private JScrollPane scrollpane;
    private JButton saveButton, openButton;
    private JLabel whiteshark;
    private Box box;
    private BufferedReader br ;
    private String str;
    private JTextArea instruct;
    private File defaultDirectory = new File("C://divelog");
    private File fileDirectory = null;
    private File currentFile= null;
    public CenterPanel()
    { // open constructor CenterPanel
    setBackground(Color.white);
    comments = new JTextArea("Enter comments, such as " +
    "location, water conditions, sea life you observed," +
    " and problems you may have encountered.", 15, 10);
    comments.setLineWrap(true);
    comments.setWrapStyleWord(true);
    comments.setEditable(true);
    comments.setFont(new Font("Times-Roman", Font.PLAIN, 14));
    // add a document listener for changes to the text,
    // query before opening a new file to decide if we need to save changes.
    MyDocumentListener myDocumentListener = new MyDocumentListener(); // define the listener class
    comments.getDocument().addDocumentListener(myDocumentListener); // create the reference for the class
    // ------ Document listener class -----------
    class MyDocumentListener implements DocumentListener {
    public void insertUpdate(DocumentEvent e) {
    Calculate(e);
    public void removeUpdate(DocumentEvent e) {
    Calculate(e);
    public void changedUpdate(DocumentEvent e) {
    private void Calculate(DocumentEvent e) {
    // do something here
    scrollpane = new JScrollPane(comments);
    scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    saveButton = new JButton("Save Comments", new ImageIcon("images/Save16.gif"));
    saveButton.addActionListener( this );
    saveButton.setToolTipText("Click this button to save the current file.");
    openButton = new JButton("Open File...", new ImageIcon("images/Open16.gif"));
    openButton.addActionListener( this );
    openButton.setToolTipText("Click this button to open a file.");
    whiteshark = new JLabel("", new ImageIcon("images/gwhite.gif"), JLabel.CENTER);
    Box boxH;
    boxH = Box.createHorizontalBox();
    boxH.add(openButton);
    boxH.add(Box.createHorizontalStrut(15));
    boxH.add(saveButton);
    box = Box.createVerticalBox();
    box.add(scrollpane);
    box.add(Box.createVerticalStrut(10));
    box.add(boxH);
    box.add(Box.createVerticalStrut(15));
    box.add(whiteshark);
    add(box);
    } // closes constructor CenterPanel
    public void actionPerformed( ActionEvent evt )
    { // open method actionPerformed
    JFileChooser jfc = new JFileChooser();
    // these do not work !!
    // -- set the file types to view --
    // ExtensionFileFilter filter = new ExtensionFileFilter();
    // FileFilter filter = new FileFilter();
    //filter.addExtension("java");
    //filter.addExtension("txt");
    //filter.setDescription("Text & Java Files");
    //jfc.setFileFilter(filter);
         //Add a custom file filter and disable the default "Accept All" file filter.
    jfc.addChoosableFileFilter(new JTFilter());
    jfc.setAcceptAllFileFilterUsed(false);
    // -- open the default directory --
    // public void setCurrentDirectory(File dir)
    // jfc.setCurrentDirectory(new File("C://divelog"));
    jfc.setCurrentDirectory(defaultDirectory);
    jfc.setSize(400, 300);
    jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    Container parent = saveButton.getParent();
    //========================= Test Button Actions ================================
    //========================= Open Button ================================
    if (evt.getSource() == openButton)
    int choice = jfc.showOpenDialog(CenterPanel.this);
    File file = jfc.getSelectedFile();
    /* a: */
    if (file != null && choice == JFileChooser.APPROVE_OPTION)
    String filename = jfc.getSelectedFile().getAbsolutePath();
    // -- compare the currentFile to the file chosen, alert of loosing any changes to currentFile --
    // If (currentFile != filename)
    // -- get the current directory name -------
    // public File getCurrentDirectory( );
    File f=new File(System.getProperty("user.dir"));
    fileDirectory = jfc.getCurrentDirectory();
    // -- remember the last directory used --
    if (defaultDirectory != fileDirectory)
    {defaultDirectory = fileDirectory;}
    try
    { //opens try         
    comments.getLineCount( );
    // -- clear the old data before importing the new file --
    comments.selectAll();
    comments.replaceSelection("");
    // -- get the new data ---
    br = new BufferedReader (new FileReader(file));
    while ((str = br.readLine()) != null)
    {//opens while
    comments.append(str);
    } //closes while
    } // close try
    catch (IOException ioe)
    { // open catch
    comments.append(newline +"Open command not successful:" + ioe + newline);
    } // close catch
    // ---- display the values of the directory variables -----------------------
    comments.append(
    newline + "The f directory variable contains: " + f +
    newline + "The fileDirectory variable contains: " + fileDirectory +
    newline + "The defaultDirectory variable contains: " + defaultDirectory );
    else
    comments.append("Open command cancelled by user." + newline);
    } //close if statement /* a: */
    //========================= Save Button ================================
    } else if (evt.getSource() == saveButton)
    int choice = jfc.showSaveDialog(CenterPanel.this);
    if (choice == JFileChooser.APPROVE_OPTION)
    File fileName = jfc.getSelectedFile();
    // -- get the current directory name -------
    // public File getCurrentDirectory( );
    File f=new File(System.getProperty("user.dir"));
    fileDirectory = jfc.getCurrentDirectory();
    // -- remember the last directory used --
    if (defaultDirectory != fileDirectory)
    {defaultDirectory = fileDirectory;}
    //check for existing files. Warn users & ask if they want to overwrite
    for(int i = 0; i < fileName.length(); i ++) {
    File tmp = null;
    tmp = (fileName);
    if (tmp.exists()) // display pop-up alert
    //public static int showConfirmDialog( Component parentComponent,
    // Object message,
    // String title,
    // int optionType,
    // int messageType,
    // Icon icon);
    int confirm = JOptionPane.showConfirmDialog(null,
    fileName + " already exists on " + fileDirectory
    + "\n \nContinue?", // msg
    "Warning! Overwrite File!", // title
    JOptionPane.OK_CANCEL_OPTION, // buttons displayed
                        // JOptionPane.ERROR_MESSAGE
                        // JOptionPane.INFORMATION_MESSAGE
                        // JOptionPane.PLAIN_MESSAGE
                        // JOptionPane.QUESTION_MESSAGE
    JOptionPane.WARNING_MESSAGE,
    null);
    if (confirm != JOptionPane.YES_OPTION)
    { //user cancels the file overwrite.
    try {
    jfc.cancelSelection();
    break;
    catch(Exception e) {}
    // ----- Save the file if everything is OK ----------------------------
    try
    { // opens try
    BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
    bw.write(comments.getText());
    bw.flush();
    bw.close();
    comments.append( newline + newline + "Saving: " + fileName.getName() + "." + newline);
    break;
    } // closes try
    catch (IOException ioe)
    { // open catch
    comments.append(newline +"Save command unsuccessful:" + ioe + newline);
    } // close catch
    } // if exists
    } //close for loop
    else
    comments.append("Save command cancelled by user." + newline);
    } // end-if save button
    } // close method actionPerformed
    } //close constructor CenterPanel
    } // Closes class CenterPanel

    There is no way to be able to see MyDocumentListener class in the way you wrote. The reason is because MyDocumentListener class inside the constructor itself. MyDocumentListener class is an inner class, not suppose to be inside a constructor or a method. What you need to do is simple thing, just move it from inside the constructor and place it between two methods.
    that's all folks
    Qusay

  • Try/catch and 'cannot resolve symbol'

    I am relatively new to java programming and something has me puzzled...
    Why do I get a 'cannot resolve symbol' message when I include a variable definition in a try/catch section. When I put it/them before the 'try' statement it compiles as expected. How are statements inside a try compiled differently than those outside?
    try {
        StringBuffer pageBuffer = new StringBuffer();
        String inputLine;
        BufferedReader in = new BufferedReader(
           new InputStreamReader( theURL.openStream() ) );
        while ((inputLine = in.readLine()) != null) {
             System.out.println(inputLine);
            pageBuffer.append(inputLine);
        in.close();
    } catch (Exception ignored) {}C:\Projects\WebExplorer\PageVisitor.java:142: cannot resolve symbol
    symbol : variable pageBuffer
    location: class PageVisitor
         return pageBuffer.toString();
    Paul

    A try block is just like any other block delimited by {...} in that all variables declared inside it are local to that block. I.e. they are not visible or usable anywhere outside it. Your pageBuffer variable, for example, is a local variable that can only be used inside the try-block in which it is declared.
    Your obvious solution, knowing that, is to declare the variables outside the try and catch blocks. Remember to initialize them (even to null), otherwise the compiler will complain about variables that may not have been initialized.

  • Compiling error - cannot resolve symbol

    Hi,
    I am working on writing out this basic code for a project. When I compile, I get an error "Cannot resolve symbol" for the gpa variable. Please help!
    My intention is to use the hours and points from the crHours and nbrPoints methods, and use them to calculate GPA in the grPtAvg method:
    public class Student
         public static void main(String[]args)
    idNum();
    crHours();
    nbrpoints();
    gpa = grPtAvg(hours, points);
    System.out.println("Student's GPA is " + gpa);
    public static void idNum()
    int id = 2520;
    System.out.println("Student's ID is " + id);
    public static float crHours()
    float hours = 5;
    System.out.println("Student's credit hours are " + hours);
    return hours;
    public static float nbrpoints()
    float points = 22;
    System.out.println("Student's earned points are " + points);
    return points;
    public static float grPtAvg(float hours, float points)
    float gpa;
    gpa = points / hours;
    System.out.println("Student's computed GPA is " + gpa);
    return gpa;

    That's because you're doing the same thing (in a somewhat different way) with those.
    The variables: hours and points have already been returned to main methd, right?Yes, but then the main method ignores them.
    So, they should be available at this point in the code, is that right?Available in the sense that you can read them, but not in the sense that there are hours and points variables within scope in the main method.
    You want to do this:
    public static void main(String[] args) {
       idNum();
       float hours = crHours();
       float points = nbrpoints();
       //create a new float
       float myComputetdGpa = grPtAvg(hours, points);
       System.out.println("Student's GPA is " + myComputedGpa);
    }

  • Solaris Deployment Failure for cannot resolve symbol on PersistentContainer

    Hello, I'm having trouble diagnosing the following deployment failure.
    What are some common causes of this? My server was created using an
    Express Integration domain with some custom JMS destinations added
    afterwards via the console. I am deploying an application built with
    Workshop (straight from workshop). I copied over an application from
    Windows to Solaris, deleted the .workshop directory and .beabuild.txt
    and rebuilt the application to deploy.
    I get this error a few times.
    ####<Aug 21, 2003 10:48:19 AM EDT> <Info> <EJB> <rhino> <cgServer>
    <ExecuteThread: '1' for queue: 'weblogic.kernel.System'> <<WLS Kernel>>
    <> <BEA-012033> <Compiling generated EJB classes produced the following
    Java compiler output:
    /export/data/ident/bea/user_projects/domains/ident1Server.conf/./cgServer/.wlnotdelete/EJBCompilerCache/-7dxi2hv35mro/com/bea/wlwgen/PersistentContainer_3fq3ar_Impl.java:143:
    cannot resolve symbol
    symbol : class BMPContainerBean$DuplicateKeyRemoteException
    location: package bean
    perchance you meant 'BMPContainerBean.DuplicateKeyRemoteException'
    throws
    com.bea.wlw.runtime.core.bean.BMPContainerBean$DuplicateKeyRemoteException
    ^
    1 error
    This then causes other errors repeating that the deployment failed (let
    me know if you need more to diagnose this):
    Exception:weblogic.management.ApplicationException: prepare failed for
    .workshop/myApp/EJB/myProc_1trtqtoxcz4uv
    Module: .workshop/myApp/EJB/myProc_1trtqtoxcz4uv Error:
    Exception preparing module:
    EJBModule(.workshop/myApp/EJB/myProc_1trtqtoxcz4uv,status=NEW)
    Unable to deploy EJB: .workshop/myApp/EJB/myProc_1trtqtoxcz4uv from
    .workshop/myApp/EJB/myProc_1trtqtoxcz4uv:
    Compiler failed executable.exec

    But by default WLS8.1 comes with jdk141_02 ...correct ?
    AND what i understand is that...the bug you posted is related to a bug in jdk1.4.2
    ....correct ??
    correct me if i wrong.
    -sangita
    Steven Ostrowski <[email protected]> wrote:
    It looks like this is a bug in the BEA-generated code that is then
    compiled by WLS. The generated code was using the Class1$Class2 notation
    to reference the class, but since $ is a valid character in the class
    name, this does not behave as intended. This used to be a bug in
    pre-1.4.2 but is now fixed in 1.4.2 (look at bug 4635044, and this is
    also mentioned in the 1.4.2 release notes and the Java Developer forums).
    The generated code should be:
    com.bea.wlw.runtime.core.bean.BMPContainerBean.DuplicateKeyRemoteException
    not
    com.bea.wlw.runtime.core.bean.BMPContainerBean$DuplicateKeyRemoteException
    Thanks again for the good response. I'll send this in to BEA support.
    Steven Ostrowski wrote:
    One other thing to add, this was fixed by changing the JAVA_HOME
    variable inside of the startWeblogic.sh script. Setting it in workshop
    did not change anything.
    Steven Ostrowski wrote:
    Wow, you hit it right on target! I was using 1.4.2 then tried it on
    1.4.1_03 and it deployed fine.
    Is this a bug in BEA or in the JDK? In either case, where should I
    report this bug?
    Thanks again
    Rob Woollen wrote:
    What version of the JDK are you using? I believe they changed the
    inner class naming conventions in 1.4.2, and it's breaking lots of
    people.
    -- Rob
    Steven Ostrowski wrote:
    Hello, I'm having trouble diagnosing the following deployment
    failure. What are some common causes of this? My server was created
    using an Express Integration domain with some custom JMS
    destinations added afterwards via the console. I am deploying an
    application built with Workshop (straight from workshop). I copied
    over an application from Windows to Solaris, deleted the .workshop
    directory and .beabuild.txt and rebuilt the application to deploy.
    I get this error a few times.
    ####<Aug 21, 2003 10:48:19 AM EDT> <Info> <EJB> <rhino> <cgServer>
    <ExecuteThread: '1' for queue: 'weblogic.kernel.System'> <<WLS
    Kernel>> <> <BEA-012033> <Compiling generated EJB classes produced
    the following Java compiler output:
    /export/data/ident/bea/user_projects/domains/ident1Server.conf/./cgServer/.wlnotdelete/EJBCompilerCache/-7dxi2hv35mro/com/bea/wlwgen/PersistentContainer_3fq3ar_Impl.java:143:
    cannot resolve symbol
    symbol : class BMPContainerBean$DuplicateKeyRemoteException
    location: package bean
    perchance you meant 'BMPContainerBean.DuplicateKeyRemoteException'
    throws
    com.bea.wlw.runtime.core.bean.BMPContainerBean$DuplicateKeyRemoteException
    ^
    1 error
    This then causes other errors repeating that the deployment failed
    (let me know if you need more to diagnose this):
    Exception:weblogic.management.ApplicationException: prepare failed
    for .workshop/myApp/EJB/myProc_1trtqtoxcz4uv
    Module: .workshop/myApp/EJB/myProc_1trtqtoxcz4uv Error:
    Exception preparing module:
    EJBModule(.workshop/myApp/EJB/myProc_1trtqtoxcz4uv,status=NEW)
    Unable to deploy EJB: .workshop/myApp/EJB/myProc_1trtqtoxcz4uv from
    .workshop/myApp/EJB/myProc_1trtqtoxcz4uv:
    Compiler failed executable.exec

  • Cannot resolve symbol

    Hello,
    I'm brand new to Java. Why is it that the compiler will not recognize my return variable??
    Thanks
    import javax.swing.*;
    import java.text.*;
    class BookOrder
         public static void main(String[] values)
              String bookCode = JOptionPane.showInputDialog("Enter your book code");
              String getResults = getResults(bookCode);
              System.exit(0);
         //End of main
         private static String getResults(String bookCode)
              if(bookCode.equals("wp"))
                   {String codeLabel = "War and Peace";}
              else if(bookCode.equals("pr"))
                   {String codeLabel = "Politics and Religion";}
              return codeLabel;
    C:\jdk1.3.1\myClasses\BookOrder.java:21: cannot resolve symbol
    symbol : variable returnCode
    location: class BookOrder
              return returnCode;
    ^

    You are out of scope. If that does not make sense, then please pick up a book on basic programming skills and start reading in chapter one. But, here is how I would fix:
    import javax.swing.*;
    import java.text.*;
    class BookOrder
    public static void main(String[] values)
    String bookCode = JOptionPane.showInputDialog("Enter your book code");
    String getResults = getResults(bookCode);
    System.exit(0);
    //End of main
    private static String getResults(String bookCode)
    String codeLabel = "";
    if(bookCode.equals("wp"))
    {codeLabel = "War and Peace";}
    else if(bookCode.equals("pr"))
    {codeLabel = "Politics and Religion";}
    return codeLabel;
    }regards,
    jarshe

  • Error: Cannot Resolve symbol

    Hi i have written this program but it is not compling properly. i do not know what to do to sort it. here is the code:
    import java.sql.*;
    import java.io.DataInputStream;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Phase1 extends JFrame implements ActionListener, MouseListener
         //Create Buttons and Text areas etc for the GUI itself
         JButton add, current, delete, order, all, exit;
         JTextField textStockCode, textStockDesc, textCurrentLevel, textReorderLevel, textPrice;
         JTextArea textarea;
         JScrollPane pane1;
         JLabel labelStockCode, labelStockDesc, labelCurrentLevel, labelReorderLevel, labelPrice, labelTextArea;
         String stockCode, stockDesc, currentLevel, reorderLevel, price;
         JLabel welcome;
         //Setup database connections and statements for later use
         Connection db_connection;
         Statement db_statement;
         public Phase1()
              //Display a welcome message before loading system onto the screen
              JOptionPane.showMessageDialog(null, "Welcome to the Stock Control System");
              //set up the GUI environment to use a grid layout
              Container content=this.getContentPane();
              content.setLayout(new GridLayout(3,6));
              //Inititlise buttons
              add=new JButton("Add");
              add.addActionListener(this);
              current=new JButton("Show Current Level");
              current.addActionListener(this);
              delete=new JButton("Delete");
              delete.addActionListener(this);
              order=new JButton("Place Order");
              order.addActionListener(this);
              all = new JButton("Show All Entries");
              all.addActionListener(this);
              exit = new JButton("Exit");
              exit.addActionListener(this);
              //Add Buttons to the layout
              content.add(add);
              content.add(current);
              content.add(delete);
              content.add(order);
              content.add(all);
              content.add(exit);
              //Initialise text fields for inputting data to the database and
              //Add mouse listeners to clear the boxs on a click event
              textStockCode = new JTextField("");
              textStockCode.addMouseListener(this);
              textStockDesc = new JTextField("");
              textStockDesc.addMouseListener(this);
              textCurrentLevel = new JTextField("");
              textCurrentLevel.addMouseListener(this);
              textReorderLevel = new JTextField("");
              textReorderLevel.addMouseListener(this);
              textPrice = new JTextField("");
              textPrice.addMouseListener(this);
              //Initialise the labels to label the Text Fields
              labelStockCode = new JLabel("Stock Code");
              labelStockDesc = new JLabel("Stock Description");
              labelCurrentLevel = new JLabel("Current Level");
              labelReorderLevel = new JLabel("Re-Order Level");
              labelPrice = new JLabel("Price");
              labelTextArea = new JLabel("All Objects");
              //Add Text fields and labels to the GUI
              content.add(labelStockCode);
              content.add(textStockCode);
              content.add(labelStockDesc);
              content.add(textStockDesc);
              content.add(labelCurrentLevel);
              content.add(textCurrentLevel);
              content.add(labelReorderLevel);
              content.add(textReorderLevel);
              content.add(labelPrice);
              content.add(textPrice);
              content.add(labelTextArea);
              //Create a text area with scroll bar for showing Entries in the text area
              textarea=new JTextArea();
              textarea.setRows(6);
              pane1=new JScrollPane(textarea);
              content.add(pane1);
              //Try to connect to the database through ODBC
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                   //Create a URL that identifies database
                   String url = "jdbc:odbc:" + "stock";
                   //Now attempt to create a database connection
                   //First parameter data source, second parameter user name, third paramater
                   //password, the last two paramaters may be entered as "" if no username or
                   //pasword is used
                   db_connection = DriverManager.getConnection(url, "demo","");
                   //Create a statement to send SQL
                   db_statement = db_connection.createStatement();
              catch (Exception ce){} //driver not found
         //action performed method for button click events
         public void actionPerformed(ActionEvent ev)
              if(ev.getSource()==add)               //If add button clicked
                   try
                        add();                         //Run add() method
                   catch(Exception e){}
              if(ev.getSource()==current)
              {     //If Show Current Level Button Clicked
                   try
                        current();                    //Run current() method
                   catch(Exception e){}
              if(ev.getSource()==delete)
              {          //If Show Delete Button Clicked
                   try
                        delete();                    //Run delete() method
                   catch(Exception e){}
              if(ev.getSource()==order)          //If Show Order Button Clicked
                   try
                        order();                    //Run order() method
                   catch(Exception e){}
              if(ev.getSource()==all)          //If Show Show All Button Clicked
                   try
                        all();                         //Run all() method
                   catch(Exception e){}
              if(ev.getSource()==exit)          //If Show Exit Button Clicked
                   try{
                        exit();                         //Run exit() method
                   catch(Exception e){}
         public void add() throws Exception           //add a new stock item
              stockCode = textStockCode.getText();
              stockDesc = textStockDesc.getText();
              currentLevel = textCurrentLevel.getText();
              reorderLevel = textReorderLevel.getText();
              price = textPrice.getText();
              if(stockCode.equals(""))
                   JOptionPane.showMessageDialog(null,"Ensure Stock Code is filled out");
              if(stockDesc.equals(""))
                             JOptionPane.showMessageDialog(null,"Ensure Description is filled out");
              if(price.equals(""))
                   JOptionPane.showMessageDialog(null,"Ensure price is filled out");
              if(currentLevel.equals(""))
                   JOptionPane.showMessageDialog(null,"Ensure Current Level is filled out");
              if(reorderLevel.equals(""))
                   JOptionPane.showMessageDialog(null,"Ensure Re-Order Level is filled out");
              else
                   //Add item to database with variables set from text fields
                   db_statement.executeUpdate("INSERT INTO stock VALUES
    ('"+stockCode+"','"+stockDesc+"','"+currentLevel+"','"+reorderLevel+"','"+price+"')");
         public void current() throws Exception      //check a current stock level
              if(textStockCode.getText().equals(""))//if no stockcode has been entered
                   JOptionPane.showMessageDialog(null,"Enter a Stock Code.");
              else
                   ResultSet resultcurrent = db_statement.executeQuery("SELECT * FROM stock WHERE StockCode = '"+textStockCode.getText()+"'");
                   textarea.setText("");
                   if(resultcurrent.next())
                        do
                             textarea.setText("Stock Code: "+resultcurrent.getString("StockCode")+"\nDescription:
    "+resultcurrent.getString("StockDescription")+"\nCurrent Level: "+resultcurrent.getInt("CurrentLevel")+"\nRe-Order Level:
    "+resultcurrent.getInt("ReorderLevel")+"\nPrice: "+resultcurrent.getFloat("Price"));
                        while(resultcurrent.next());
                   else
                        //Display Current Stock Item (selected from StockCode Text field in the scrollable text area
                        JOptionPane.showMessageDialog(null,"Not a valid Stock Code");
         public void delete() throws Exception          //delete a current stock item
              if(textStockCode.getText().equals(""))          //Check there is a stock code entered
                   JOptionPane.showMessageDialog(null,"Enter a Stock Code.");
              else
                   //Delete Item from database where Stock Code is what is in Stock Code Text Field
                   db_statement.executeUpdate("DELETE * FROM stock WHERE StockCode='"+textStockCode.getText()+"'");
         public void order() throws Exception           //check price for an order
              if(textStockCode.getText().equals(""))          //Check there is a stock code entered
                   JOptionPane.showMessageDialog(null,"Enter a Stock Code.");
              else
                   //Set some variables to aid ordering
                   float price = 0;
                   int currentlevel = 0;
                   int newlevel = 0;
                   int reorder = 0;
                   String StockCode = textStockCode.getText();
                   //Post a message asking how many to order
                   String str_quantity = JOptionPane.showInputDialog(null,"Enter Quantity: ","Adder",JOptionPane.PLAIN_MESSAGE);
                   int quantity = Integer.parseInt(str_quantity);
                   //Get details from database for current item
                   ResultSet resultorder = db_statement.executeQuery("SELECT * FROM stock WHERE StockCode='"+StockCode+"'");
                   //Set variables from database to aid ordering
                   while (resultorder.next())
                        price = resultorder.getFloat("Price");
                        currentlevel = (resultorder.getInt("CurrentLevel"));
                        reorder = (resultorder.getInt("ReorderLevel"));
                   //Set the new level to update the database
                   newlevel = currentlevel - quantity;
                   //calculate the total price of the order
                   float total = price * quantity;
                   //If the stock quantity is 0
                   if(quantity == 0)
                        //Display a message saying there are none left in stock
                        JOptionPane.showMessageDialog(null,"No Stock left for this item");
                   //Otherwise check that the quantity ordered is more than what is lewft in stock
                   else if(quantity > currentlevel)
                        //If ordered too many display a message saying so
                        JOptionPane.showMessageDialog(null,"Not enough in stock, order less");
                   else
                        //Otherwise Display the total in a message box
                        JOptionPane.showMessageDialog(null,"Total is: "+total);
                        //then update the database with new values
                        db_statement.executeUpdate("UPDATE Stock SET CurrentLevel="+newlevel+" WHERE StockCode='"+StockCode+"'");
                        //Check if the new level is 0
                        if(newlevel == 0)
                             //If new level IS 0, send a message to screen saying so
                             JOptionPane.showMessageDialog(null,"There is now no Stock left.");
                        else
                             //otherwise if the newlevel of stock is the same as the reorder level
                             if(newlevel == reorder)
                                  // display a message to say so
                                  JOptionPane.showMessageDialog(null,"You are now at the re-order level, Get some more of this item in
    stock.");
                             //Otherwise if the new level is lower than the reorder level,
                             if(newlevel < reorder)
                                  //Display a message saying new level is below reorder level so get some more stock
                                  JOptionPane.showMessageDialog(null,"You are now below the reorder level. Get some more of this item in
    stock.");
         public void all() throws Exception                //show all stock items and details
              //Get everthing from the database
              ResultSet resultall = db_statement.executeQuery("SELECT * FROM Stock");
              textarea.setText("");
              while (resultall.next())
                   //Display all items of stock in the Text Area one after the other
                   textarea.setText(textarea.getText()+"Stock Code: "+resultall.getString("StockCode")+"\nDescription:
    "+resultall.getString("StockDescription")+"\nCurrent Level: "+resultall.getInt("CurrentLevel")+"\nRe-Order Level:
    "+resultall.getInt("ReorderLevel")+"\nPrice: "+resultall.getFloat("Price")+"\n\n");
         public void exit() throws Exception           //exit
              //Cause the system to close the window, exiting.
              db_connection.commit();
              db_connection.close();
              System.exit(0);
         public static void main(String args[])
              //Initialise a frame
              JDBCFrame win=new JDBCFrame();
              //Set the size to 800 pixels wide and 350 pixels high
              win.setSize(900,350);
              //Set the window as visible
              win.setVisible(true);
              win.addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent e)
                        System.exit(0);
         //Mouse Listener Commands
         public void mousePressed(MouseEvent evt)
              if (evt.getSource()==textStockCode)
                   //Clear the Stock Code text field on clickin on it
                   textStockCode.setText("");
              else if (evt.getSource()==textStockDesc)
                   //Clear the Stock Description text field on clickin on it
                   textStockDesc.setText("");
              else if (evt.getSource()==textCurrentLevel)
                   textCurrentLevel.setText("");
                   //Clear the Current Level text field on clickin on it
              else if (evt.getSource()==textReorderLevel)
                   textReorderLevel.setText("");
                   //Clear the Re-Order Level text field on clickin on it
              else if (evt.getSource()==textPrice)
                   textPrice.setText("");
                   //Clear the Price text field on clickin on it
         public void mouseReleased(MouseEvent evt){}
         public void mouseClicked(MouseEvent evt){}
         public void mouseEntered(MouseEvent evt){}
         public void mouseExited(MouseEvent evt){}
    }And this is the error that i get when compiling:
    Phase1.java:355: cannot resolve symbol
    symbol  : class JDBCFrame
    location: class Phase1
                    JDBCFrame win=new JDBCFrame();
                    ^
    Phase1.java:355: cannot resolve symbol
    symbol  : class JDBCFrame
    location: class Phase1
                    JDBCFrame win=new JDBCFrame();Thanks for any help you can give me

    The error is very clear here
    Phase1.java:355: cannot resolve symbolsymbol : class JDBCFramelocation: class Phase1 JDBCFrame win=new JDBCFrame();
    Where is this class JDBCFrame()?
    Import that package or class

  • Compilation problem (cannot resolve symbol)

    I have searched the Forums for "cannot resolve symbol" and as usual, many posts with no answers or just advise that noone ever comes back to say works. I am trying to compile this code:
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import org.acme.*;
    public class HelloOpenEJB extends HttpServlet {
    String factory = "org.openejb.client.LocalInitialContextFactory";
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    try{
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, factory );
    InitialContext ctx = new InitialContext( p );
    //Lookup the bean using it's deployment id
    Object obj = ctx.lookup("/Hello");
    HelloHome ejbHome = (HelloHome) obj;
    //Use the HelloHome to create a HelloObject
    HelloHome ejbHome = (HelloHome)
    PortableRemoteObject.narrow(obj, HelloHome.class);
    //The part we've all been wainting for...
    out.println("<html>");
    out.println("<body>");
    out.println("<head>");
    out.println("<title>Hello World!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>"+ ejbObject.sayHello() +"</h1>");
    out.println("</body>");
    out.println("</html>");
    } catch (Exception e){
    response.setContentType("text/plain");
    e.printStackTrace(out);
    I'm running this on a Linux box. When I compile, I get this:
    HelloOpenEJB.java:28: ejbHome is already defined in doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    HelloHome ejbHome = (HelloHome)
    ^
    HelloOpenEJB.java:29: cannot resolve symbol
    symbol : variable PortableRemoteObject
    location: class HelloOpenEJB
    PortableRemoteObject.narrow(obj, HelloHome.class);
    ^
    HelloOpenEJB.java:38: cannot resolve symbol
    symbol : variable ejbObject
    location: class HelloOpenEJB
    out.println(""+ ejbObject.sayHello() +"");
    ^
    3 errors
    I don't know why any of these errors are occuring, besides the obvious responses given back from javac, so can someone help? Thanks, Jeremy

    The error message "x already defined in y" means that you're trying to use a name that already exists in the current scope. In your case you have:
    HelloHome ejbHome = (HelloHome) obj;
    //Use the HelloHome to create a HelloObject
    HelloHome ejbHome = (HelloHome)
    PortableRemoteObject.narrow(obj, HelloHome.class);Here you are trying to declare two instances of HelloHome with the same name.
    The reason that you would get "cannot resolve symbol" is that you are trying to access a variable or class that you haven't declared or imported.

  • Cannot resolve symbol-- data access problem

    hi, everyone, i am new to java... thx for helping me.
    i have two files
    1) dls.java
    2) SliderDemo.java
    in the dls.java i have the following coding:
    JPanel slider = new SliderDemo(this);
    slider.framesPerSecond(0);
    and in the SliderDemo.java i have following coding:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class SliderDemo extends JPanel implements ActionListener {
    //This label uses ImageIcon to show the doggy pictures.
    JLabel picture;
    dls mydls;
    JSlider framesPerSecond;
    int i;
    public SliderDemo(dls mydls) {
    this.mydls = mydls;
    framesPerSecond = new JSlider(JSlider.HORIZONTAL, -10, 10, 0);
    framesPerSecond.addChangeListener(new SliderListener());
    //Turn on labels at major tick marks.
    framesPerSecond.setMajorTickSpacing(10);
    framesPerSecond.setMinorTickSpacing(1);
    framesPerSecond.setPaintTicks(true);
    framesPerSecond.setPaintLabels(true);
    framesPerSecond.setBorder( BorderFactory.createEmptyBorder(0,0,10,0));
    .....etc
    when i compile the dls.java
    it told me cannot resolve symbol , framePerSecond...
    help!!!why i can't resolve the symbol?
    thx all experts.
    yours,
    Terry

    cannot resolve symbol , framePerSecondPerhaps because you declared a variable whose name is "framesPerSecond" and then you tried to use "framePerSecond" instead of that?

  • Error : Cannot resolve symbol shape

    I get the following error message
    <---------------------------------------------------------------------->
    C:\RandomShapeApplet.java:87: cannot resolve symbol
    symbol : variable shape
    location: class RandomShapeApplet
              return shape;
    ^
    1 error
    Tool completed with exit code 1
    <---------------------------------------------------------------------->
    RandomShapeApplet.java
    <---------------------------------------------------------------------->
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.Rectangle2D;
    import java.awt.geom.Ellipse2D;
    import java.awt.geom.Line2D;
    import java.awt.Shape;
    import java.util.Random;
    public class RandomShapeApplet extends Applet
         Random generator;
         private double width;
         private double height;
         private double x1;
         private double y1;
         private double x2;
         private double y2;
         private double xTopLeft;
         private double yTopLeft;
         private double wdth;
         private double hght;
         private final double MIN = 0;
         private int rndValue;
         public RandomShapeApplet()
              generator = new Random();
              width = getWidth();
              height = getHeight();
         public Shape randomShape()
              rndValue = generator.nextInt(3);
              x1 = generator.nextDouble() * ((width + 1) - MIN) + MIN;
              y1 = generator.nextDouble() * ((height + 1) -MIN) + MIN;
              x2 = generator.nextDouble() * ((width + 1) - MIN) + MIN;
              y2 = generator.nextDouble() * ((height + 1) -MIN) + MIN;
              if (rndValue == 0 || rndValue == 1)
                   hght = Math.abs(y2 - y1);
                   wdth = Math.abs(x2 - x1);
                   if (y2 > y1)
                        yTopLeft = y1;
                   else if (y1 >= y2)
                        yTopLeft = y2;
                   if (x2 > x1)
                        xTopLeft = x1;
                   else if (x1 >= x2)
                        xTopLeft = x2;
                   if (rndValue == 0)
                        Rectangle2D.Double shape = new Rectangle2D.Double(xTopLeft, yTopLeft, wdth, hght);
                   else if (rndValue == 1)
                        Ellipse2D.Double shape = new Ellipse2D.Double(xTopLeft, yTopLeft, wdth, hght);
              else if (rndValue == 2)
                   Line2D.Double shape = new Line2D.Double(x1, y1, x2, y2);
              return shape;
         public void paint(Graphics g)
              Graphics2D g2 = (Graphics2D)g;
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());
              g2.draw(randomShape());

    The problem is in this part of your code...
    if (rndValue == 0)
       Rectangle2D.Double shape = new Rectangle2D.Double(xTopLeft, yTopLeft, wdth, hght);
    else if (rndValue == 1)
       Ellipse2D.Double shape = new Ellipse2D.Double(xTopLeft, yTopLeft, wdth, hght);
    else if (rndValue == 2)
       Line2D.Double shape = new Line2D.Double(x1, y1, x2, y2);
    return shape;In the code, the variable shape is always defined within {} which means the scope of the variable is only between the {}. So you can not return shape because you have not defined a variable named shape outside of the if statements. I think it will work to use
    Shape shape=null;
    if (rndValue == 0)
       shape = (Shape) new Rectangle2D.Double(xTopLeft, yTopLeft, wdth, hght);
    }And make similar changes to the rest of the code. I am assuming the rest of the objects also implement the Shape interface.

  • Cannot resolve symbol : import

    I've never had this type of error while doing a compile before.
    Does this mean that java doesn't know where to find my org.nipr.gateway_ws.utils.ConnectionPoolSingleton?
        [javac] Compiling 1 source file to C:\Data\StateProcessWebService\Server\build\war\WEB-INF\classes
        [javac] C:\Data\StateProcessWebService\Server\src\org\nipr\StateProcess\impl\StateProcessImpl.java:20: cannot resolve symbol
        [javac] symbol  : class ConnectionPoolSingleton
        [javac] location: package utils
        [javac] import org.nipr.gateway_ws.utils.ConnectionPoolSingleton;
        [javac] ^
        [javac] C:\Data\StateProcessWebService\Server\src\org\nipr\StateProcess\impl\StateProcessImpl.java:265: cannot resolve symbol
        [javac] symbol  : variable ConnectionPoolSingleton
        [javac] location: class org.nipr.StateProcess.impl.StateProcessImpl
        [javac] ConnectionPooler pool = ConnectionPoolSingleton.instance( "stateProcess" );
        [javac] ^

    Cool. Thanks.
    I freaked when I first saw that. I added the missing java file and it compiled just fine.

  • Import javax.ejb.EJBHome; cannot resolve symbol

    Hi i wonder if anyone can help me. I have read alot of the posts regarding this issue and have tried everything to do with the paths and environmental variables and even reinstalled everything.
    import javax.ejb.EJBHome; cannot resolve symbol
    This is the problem i keep getting and here are the paths that i set:
    SET PATH=c:\j2sdkee1.3\bin;c:\jdk1.3.1_01\bin;c:\jakarta-ant-1.3\bin
    SET ANT_HOME=c:\jakarta-ant-1.3
    SET JAVA_HOME=c:\jdk1.3.1_01
    SET J2EE_HOME=c:\j2sdkee1.3
    SET CLASSPATH=c:\j2sdkee1.3\lib\j2ee.jar;c:\jakarta-ant-1.3\lib\ant.jar;c:\jdk1.3.1_01\lib\tools.jar
    What am i doing wrong???

    Im not sure, everything looks ok to me, but here is what i tried:
    I wrote this little test class, and compiled it
    import javax.ejb.EJBHome;
    public class test
    public test()
    I got the same error you did (or similar)
    D:\>javac test.java
    test.java:1: package javax.ejb does not exist
    import javax.ejb.EJBHome;
    ^
    1 error
    then I added the j2ee.jar to my classpath and everything worked fine.
    here are my env vars:
    JAVA_HOME=d:\dev\jdk
    J2EE_HOME=d:\dev\j2sdkee
    CLASSPATH=...;%J2EE_HOME%\lib\j2ee.jar
    If I were you I would double check all the paths you have set up then try a simple case like the one above. If your running NT/2000 make sure the JAVA_HOME, J2EE_HOME and CLASSPATH are system variables not user variables. Another thing you can try is adding the j2ee.jar to the classpath with the -classpath compiler switch.
    javac -classpath %CLASSPATH%;d:\dev\j2sdkee\lib\j2ee.jar test.java
    Other than those things I'm not sure
    Good Luck

  • Cannot resolve symbol dropdown1 from the tutorial

    Has anyone a clue to why javac won't compile the button action. I looks like it can't find the dropdown1 droplist despite the fact that it is visible in the gui editor.
    here is my offending code:
    String name=(String)dropdown1.getValue();
    And the error code:
    untitled\Page1.java [76] cannot resolve symbol
    symbol : variable dropdown1
    location: class untitled.Page1
    String name=(String)dropdown1.getValue();

    Sounds like a bug.
    I'm sure the engineering team would love to have some more info on this. Can you file a bug here:
    http://developers.sun.com/prodtech/javatools/jscreator/bugreport.jsp
    From my experience, they are taken very seriously and if it's already filed and has workaround, it'll be sent to you.
    For sending the source code, I'm simply meant pasting it into the message box (using eventually  formatting (see "code" button).
    thanks,
    -Alexis

Maybe you are looking for

  • Could not complete your request because of a program error when try to place embedded some file

    Hi im use the Ps CC2014 with OS yosemite. So when i try to Place some element the software shows me this Please, somebody have this error? also appears when i try to open, or use Place Linked and i must to stop my work and restart Ps again, this crea

  • Netscape 7.2 for OS 9.2.2

    I cannot find Netscape 7.2 or higher for OS 9.2.2 on my iMac 333. This is the only browser which will apparently work for an income tax program which I will be using this year. I am using IE 5.1 which will not work. I can't download from the Netscape

  • Very Slow Internet + High Ping

    I am on a Sager laptop running Windows 7 and using an Airport Extreme Base Station as my router. I don't know how the router is set up or even how to access the router from my computer. My roommate set up the internet before I moved in. I have alread

  • Mac Mini and Apple 30inch Cinema Display connectivity.

    Hi everyone, I have one simple question - if I buy the newest model mac mini, can I plug my 30inch aluminium cinema display straight into the Thunderbolt port and experience full resolution display on the monitor? Many thanks, Andy

  • Dynamic Column Names from one table and its corresponding values from another table

    I have 2 tables. First tables gives the specification if a column is required or not. we have the 2nd table with the same column name where we provide the actual values. I want to select all the required columns from the 1st table and retrieve the va