Need help with class info and cannot find symbol error.

I having problems with a cannot find symbol error. I cant seem to figure it out.
I have about 12 of them in a program I am trying to do. I was wondering if anyone could help me out?
Here is some code I am working on:
// This will test the invoice class application.
// This program involves a hardware store's invoice.
//import java.util.*;
public class InvoiceTest
     public static void main( String args[] )
     Invoice invoice1 = new Invoice( "1234", "Hammer", 2, 14.95 );
// display invoice1
     System.out.println("Original invoice information" );
     System.out.println("Part number: ", invoice1.getPartNumber() );
     System.out.println("Description: ", invoice1.getPartDescription() );
     System.out.println("Quantity: ", invoice1.getQuantity() );
     System.out.println("Price: ", invoice1.getPricePerItem() );
     System.out.println("Invoice amount: ", invoice1.getInvoiceAmount() );
// change invoice1's data
     invoice1.setPartNumber( "001234" );
     invoice1.setPartDescription( "Yellow Hammer" );
     invoice1.setQuantity( 3 );
     invoice1.setPricePerItem( 19.49 );
// display invoice1 with new data
     System.out.println("Updated invoice information" );
     System.out.println("Part number: ", invoice1.getPartNumber() );
     System.out.println("Description: ", invoice1.getPartDescription() );
     System.out.println("Quantity: ", invoice1.getQuantity() );
     System.out.println("Price: ", invoice1.getPricePerItem() );
     System.out.println("Invoice amount: ", invoice1.getInvoiceAmount() );
and that uses this class file:
public class Invoice
private String partNumber;
private String partDescription;
private int quantityPurchased;
private double pricePerItem;
     public Invoice( String ID, String desc, int purchased, double price )
          partNumber = ID;
     partDescription = desc;
     if ( purchased >= 0 )
     quantityPurchased = purchased;
     if ( price > 0 )
     pricePerItem = price;
public double getInvoiceAmount()
     return quantityPurchased * pricePerItem;
public void setPartNumber( String newNumber )
     partNumber = newNumber;
     System.out.println(partDescription+" has changed to part "+newNumber);
public String getPartNumber()
     return partNumber;
public void setDescription( String newDescription )
     System.out.printf("%s now refers to %s, not %s.\n",
partNumber, newDescription, partDescription);
     partDescription = newDescription;
public String getDescription()
     return partDescription;
public void setPricePerItem( double newPrice )
     if ( newPrice > 0 )
pricePerItem = newPrice;
public double getPricePerItem()
return pricePerItem;
Any tips for helping me out?

System.out.println("Part number:
"+invoice1.getPartNumber;
The + sign will concatenate invoice1.getPartNumber()
after "Part number: " forming only one String.I added the plus sign and it gives me more errors:
C:\>javac InvoiceTest.java
InvoiceTest.java:16: operator + cannot be applied to java.lang.String
        System.out.println("Part number: ",   + invoice1.getPartNumber() );
                                              ^
InvoiceTest.java:17: cannot find symbol
symbol  : method getPartDescription()
location: class Invoice
        System.out.println("Description: ", + invoice1.getPartDescription() );
                                                      ^
InvoiceTest.java:17: cannot find symbol
symbol  : method println(java.lang.String,int)
location: class java.io.PrintStream
        System.out.println("Description: ", + invoice1.getPartDescription() );
                  ^
InvoiceTest.java:18: cannot find symbol
symbol  : method getQuantity()
location: class Invoice
        System.out.println("Quantity: ", + invoice1.getQuantity() );
                                                   ^
InvoiceTest.java:18: cannot find symbol
symbol  : method println(java.lang.String,int)
location: class java.io.PrintStream
        System.out.println("Quantity: ", + invoice1.getQuantity() );
                  ^
InvoiceTest.java:19: cannot find symbol
symbol  : method println(java.lang.String,double)
location: class java.io.PrintStream
        System.out.println("Price: ", + invoice1.getPricePerItem() );
                  ^
InvoiceTest.java:20: cannot find symbol
symbol  : method println(java.lang.String,double)
location: class java.io.PrintStream
        System.out.println("Invoice amount: ", + invoice1.getInvoiceAmount() );
                  ^
InvoiceTest.java:24: cannot find symbol
symbol  : method setPartDescription(java.lang.String)
location: class Invoice
        invoice1.setPartDescription( "Yellow Hammer" );
                ^
InvoiceTest.java:25: cannot find symbol
symbol  : method setQuantity(int)
location: class Invoice
        invoice1.setQuantity( 3 );
                ^
InvoiceTest.java:30: operator + cannot be applied to java.lang.String
        System.out.println("Part number: ", + invoice1.getPartNumber() );
                                            ^
InvoiceTest.java:31: cannot find symbol
symbol  : method getPartDescription()
location: class Invoice
        System.out.println("Description: ", + invoice1.getPartDescription() );
                                                      ^
InvoiceTest.java:31: cannot find symbol
symbol  : method println(java.lang.String,int)
location: class java.io.PrintStream
        System.out.println("Description: ", + invoice1.getPartDescription() );
                  ^
InvoiceTest.java:32: cannot find symbol
symbol  : method getQuantity()
location: class Invoice
        System.out.println("Quantity: ", + invoice1.getQuantity() );
                                                   ^
InvoiceTest.java:32: cannot find symbol
symbol  : method println(java.lang.String,int)
location: class java.io.PrintStream
        System.out.println("Quantity: ", + invoice1.getQuantity() );
                  ^
InvoiceTest.java:33: cannot find symbol
symbol  : method println(java.lang.String,double)
location: class java.io.PrintStream
        System.out.println("Price: ", + invoice1.getPricePerItem() );
                  ^
InvoiceTest.java:34: cannot find symbol
symbol  : method println(java.lang.String,double)
location: class java.io.PrintStream
        System.out.println("Invoice amount: ", + invoice1.getInvoiceAmount() );
                  ^
16 errors

Similar Messages

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

  • Need help with Class-Path and NCDFE

    This isn't a new issue, but I'm getting a variation of a problem a lot of people seem to have had. I was hoping someone out there can help me out.
    I have a jar file (imex.jar) sitting in c:\temp\imextest. I also have another jar file, commons-cli-1.0.jar sitting in c:\temp\imextest\lib.
    I want to run the jar in a standalone manner. My manifest has the following entries.
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.5.3
    Created-By: 1.4.2_01-b06 (Sun Microsystems Inc.)
    Main-Class: com.foo.imex.DirectoryImportExport
    Class-Path: lib/commons-cli-1.0.jar
    I am invoking it using the following command (from c:\temp\imextest)
    java -jar imex.jar -i -f c:\matt\RRBus\jiyun.xml -v
    I get this result:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
    It seems to me that I have my directory structure and manifest set up correctly, but maybe I don't (as it's not working). Does anyone see what I'm doing wrong here? (the "missing" class is in commons-cli-1.0.jar).
    Thanks,
    Matt

    perhaps jar file needed for parsing is not there in classpath...set it...in the classpath..

  • Need help with RAID Card and degraded Raid-5 errors

    Dear all,
    I recently purchased a used Apple RAID card for my 2008 Mac Pro 8-Core. The installation went smooth, the card was immediately recognized and the battery reconditioned within one night.
    So I started setting up a Raid Set with the 4 identical drives which I already used before as a software Raid. But each time the Raid Level-5 Volume is created, somewhat later the status turns red and the Raid is listed as "degraded"!
    A closer look at log reveals:
    +19:42:54 Drive carrier 00:01 inserted+
    +19:42:27 Background task aborted: Task=Init,Scope=DRVGRP,Group=RS1+
    +19:42:27 Degraded RAID set RS1 - No spare available for rebuild+
    +19:42:26 Degraded RAID set RS1+
    +19:42:22 Drive carrier 00:01 removed+
    +15:10:57 Created volume “R1V1” on RAID set “RS1”+
    So it seems that the drive from Bay 1 somehow gets lost (removed) a few hours after the volume is being created and anysoon later it's being "reinserted"...
    Of course, the drive is NOT removed, nobody touched the Mac Pro! Also I did the same procedure 3 times and the result was always the same.
    I also tried setting up JBOD and different RAID levels which do all work without a problem. Only when choosing RAID5 (what I intentionally bought the card for), the problem reappears
    Anyone any solution or hint for me concerning this problem? Many thanks in advance!

    One drive completely broke down later. Replaced that drive and since the problem's gone!

  • Please help with cannot find symbol error. Been struggling all day :(

    Hi all. :)
    Writing a game for my phone with KToolbar and have been getting a cannot find symbol error for every variable and method I try to use across Classes. I've looked all over and though it seems a common problem I always either don't understand or can't get working the various solutions. Example of my errors:
    C:\...\BTK800i.java:197: cannot find symbol
    symbol : variable youSayWhat
    location: class HelloCanvas
              youSayWhat=key;
              ^
    If I try BTK800i.variable or BTK800i.message I get a new error.
    C:\...\src\BTK800i.java:184: non-static method newOrdersSarge() cannot be referenced from a static context
              BTK800i.newOrdersSarge();
              ^
    Both these errors apply to both variables and methods. It only happens when I'm using methods/variables of one class in another, am I using public and private incorrectly? It doesn't seem to make a difference if I make variables public or leave them private, I'm trying to get to them with a public method within a private class. Is it something else? I really have no idea. :(
    Here's my code, it's long enough to be a tiresome read so I've tried to skip what I know isn't relevant.
    public class BTK800i extends MIDlet {
         private Display myDisplay;
         private HelloCanvas myCanvas;
         public int youSayWhat;
            //a whole bunch more skipped here, but I'm fairly certain it's not anything that'll help find a solution
         public BTK800i() {
              paused=false;
    public void startApp() throws MIDletStateChangeException {
              if( paused ) {
                   myCanvas.repaint();
              else {
                   myDisplay=Display.getDisplay(this);
                   myCanvas=new HelloCanvas();
                   myDisplay.setCurrent(myCanvas);
                   myCanvas.setFullScreenMode(true);
                   youSayWhat=0;
                           //again with the skipping, more code not related
    public void newOrdersSarge() {
    //whole bunch of code
    //other methods skipped
    class HelloCanvas extends Canvas {
         public void keyPressed (int key) {
              youSayWhat=key;
              repaint ();
    //skippage
    }The stuff I skipped is mainly either more of the same sorta thing or maths/writing to screen stuff.
    Thanks alot to anyone who helps. I'm really struggling with this. :(
    Dan.

    But I have been reading them :(
    My next-door neighbour unfortunately is an 80-something married man, but I will go have a looksie about static and instances.
    I thought the point of public variables was that other classes could use them, is this wrong?
    Also does this mean that to use the variables from my BTK class in the HelloCanvas class I need to first instantiate BTK? I don't understand how that works as the code starts running from the BTK class in the first place :S I guess more reading will help with this.
    Thanks very much for replying. :)
    Edit:
    OK I have read up on it but I don't think I found anything I hadn't read before. I tried to make a new class which I could instantiate to hold all the variables and methods I wanted everything to be able to access, but that went disastrously. Am I right in understanding that there are no global variables in Java? :s
    Edited by: Dan69 on Apr 17, 2010 1:15 PM

  • Need help with Blog, Wiki and Gallery

    Hi Team,
    Need help with Blog, Wiki and Gallery startup. I have newly started visiting forums and quite interested to contribute towards these areas also.
    Please help.
    Thanks,
    Santosh Singh
    Santosh Singh

    Hello Santhosh,
    Blog is for Microsoft employees only. However, you can contribute towards WIKI and GALLERY using the below links.
    http://social.technet.microsoft.com/wiki/
    http://gallery.technet.microsoft.com/

  • Help! Getting the cannot find symbol error.

    Hello everyone. I have gone throught my whole program and I am still getting a cannot find symbol error. What does this error mean exactly? Here is the code below. I am trying to color a background using a comobox method.
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.ButtonGroup;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.border.EtchedBorder;
    import javax.swing.border.TitledBorder;
    import java.awt.GridLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JComboBox;
    public class ComboboxFrame extends JFrame
        public ComboboxFrame()
            colorPanel = new JPanel();
            colorPanel.setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
            getContentPane().add(colorPanel, BorderLayout.CENTER);
            class ChoiceListener implements ActionListener
                public void actionPerformed(ActionEvent event)
                    setbackgroundColor();
            listener = new ChoiceListener();
            createControlPanel();
            setbackgroundColor();
            pack();
        private void createControlPanel()
          JPanel colorPanel = createComboBox();
          JPanel controlPanel = new JPanel();
          controlPanel.setLayout(new GridLayout(1, 1));
          controlPanel.add(colorPanel);
          getContentPane().add(
             controlPanel, BorderLayout.SOUTH);
       public JPanel createComboBox()
          colorCombo = new JComboBox();
          colorCombo.addItem("Red");
          colorCombo.addItem("Green");
          colorCombo.addItem("Blue");
          colorCombo.setEditable(true);
          colorCombo.addActionListener(listener);
          JPanel panel = new JPanel();
          panel.add(colorCombo);
          return panel;
       public void setbackgroundColor()
           String color = (String)colorCombo.getSelectedItem();
           colorPanel.setbackgroundColor(new backgroungColor(color));
           colorPanel.repaint();
       private JPanel colorPanel; 
       private static final int PANEL_WIDTH = 300;
       private static final int PANEL_HEIGHT = 300;
       private JComboBox colorCombo;
       private ActionListener listener;
    }The line with the error is: colorPanel.setbackgroundColor(new backgroungColor(color));
    Here is the second file
    import javax.swing.JFrame;
    public class backgroundTest
        public static void main(String[] args)
            JFrame frame = new comboboxFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.show();
    }Any help would be appreciated. Thank you

    Hello everyone. I have gone throught my whole
    program and I am still getting a cannot find symbol
    error. "Symbol" here means variable or method name (or maybe class name, but I think it will specifically bitch about classnames in that case).
    String foo = "foo";
    System.out.println(zoo); // no such variable as zoo. So...
    colorPanel.setbackgroundColor(new backgroungColor(color));Looks like colorPanel or setbackgroundColor(new backgroungColor doesn't exist.
    Note that spelling and capitalization count. Java's really anal that way.

  • Help - cannot find symbol error

    Can someone help me? I am getting "cannot find symbol" error in my code and cannot figure out why. Here is my code:
    public class toyInventory
    private String[] toyInventory = {"ball", "bat", "bear", "car", "doll", "game", "glove", "playstation", "train"};
    private int[] nineArray = {0,0,0,0,0,0,0,0};
    int invItems = 0;
    public void countToy()
    String orderInput[] = {"bear", "train", "car", "ball", "doll", "ball", "train", "doll", "game", "train", "bear", "doll", "train", "car", "ball", "bat", "glove", "bat", "b", "doll", "bear", "ball", "doll", "bat", "car", "glove", "train", "doll", "bear"};
    int noMatch;
    for(int a = 0; a < orderInput.length; a++)
    noMatch = 0;
    for(int b = 0; b < toyInventory.length; b++)
    if(orderInput[a] == toyInventory)
    noMatch = 1;
    break;
    if(noMatch == 0)
    invItems = 1;
    public void printItems()
    for(int c = 0; c < toyInventory.length; c++)
    if (countToy[c] > 4)<-------- cannot find symbol error here
    System.out.print("*");
    System.out.print(toyInventory[c] + "\t" + countToy[c] + "\n"); <----cannot find symbol error here also
    System.out.print("The number of invalid items in the order is" + invItems);
    public static void main( String[] args)
    toyInventory collection = new toyInventory ();
    collection.countToy();
    collection.printItems();

    public void countToy()
    String orderInput[] = {"bear", "train", "car", "ball", "doll", "ball", "train", "doll", "game", "train", "bear", "doll", "train", "car", "ball", "bat", "glove", "bat", "b", "doll", "bear", "ball", "doll", "bat", "car", "glove", "train", "doll", "bear"};In the above code you have declared countToy() as method and while in the below lines you are calling countToy[] as an array. So please check that...
    if (countToy[c] > 4)<-------- cannot find symbol error here
    System.out.print("*");
    System.out.print(toyInventory[c] + "\t" + countToy[c] + "\n"); <----cannot find symbol error here also
    }

  • Cannot find package error and cannot resolve symbol error

    Hi
    I have a file Assignment.java in C:\TIJCode\c03 folder. But this file belongs to the default package. This file imports a package com.bruceeckel.simpletest which is in C:\TIJCode\ folder. Now this package has a file named Test.java which accesses a few more files fromt he same package.
    I set the classpath to C:\TIJCode. When i try to run the Assignment file I get an error saying package com.bruceeckel.simpletest cannot be found and cannot resolve symbol error. symbol: Test Class: Assignment.
    The files in com.bruceeckel.simpletest package were not compiled. So I first tried to do that. But I get a cannot resolve symbol error while trying to compile a file NumOfLinesException which inherits SImpleTestException file. The exact error message is
    NumOfLinesException.java : 7 : cannot resolve symbol
    symbol : class SimpleTestException
    location : class com.bruceeckel.simpletest.NumOfLinesException extends SimpleTestException
    The exact code in each of above mentioned files is
    //: c03:Assignment.java
    // Assignment with objects is a bit tricky.
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    import com.bruceeckel.simpletest.*;
    class Number {
    int i;
    public class Assignment {
    static Test monitor = new Test();
    public static void main(String[] args) {
    Number n1 = new Number();
    Number n2 = new Number();
    n1.i = 9;
    n2.i = 47;
    System.out.println("1: n1.i: " + n1.i +
    ", n2.i: " + n2.i);
    n1 = n2;
    System.out.println("2: n1.i: " + n1.i +
    ", n2.i: " + n2.i);
    n1.i = 27;
    System.out.println("3: n1.i: " + n1.i +
    ", n2.i: " + n2.i);
    monitor.expect(new String[] {
    "1: n1.i: 9, n2.i: 47",
    "2: n1.i: 47, n2.i: 47",
    "3: n1.i: 27, n2.i: 27"
    } ///:~
    //: com:bruceeckel:simpletest:SimpleTestException.java
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    package com.bruceeckel.simpletest;
    public class SimpleTestException extends RuntimeException {
    public SimpleTestException(String msg) {
    super(msg);
    } ///:~
    //: com:bruceeckel:simpletest:NumOfLinesException.java
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    package com.bruceeckel.simpletest;
    public class NumOfLinesException extends SimpleTestException {
    public NumOfLinesException(int exp, int out) {
    super("Number of lines of output and "
    + "expected output did not match.\n" +
    "expected: <" + exp + ">\n" +
    "output: <" + out + "> lines)");
    } ///:~
    //: com:bruceeckel:simpletest:Test.java
    // Simple utility for testing program output. Intercepts
    // System.out to print both to the console and a buffer.
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    package com.bruceeckel.simpletest;
    import java.io.*;
    import java.util.*;
    import java.util.regex.*;
    public class Test {
    // Bit-shifted so they can be added together:
    public static final int
    EXACT = 1 << 0, // Lines must match exactly
    AT_LEAST = 1 << 1, // Must be at least these lines
    IGNORE_ORDER = 1 << 2, // Ignore line order
    WAIT = 1 << 3; // Delay until all lines are output
    private String className;
    private TestStream testStream;
    public Test() {
    // Discover the name of the class this
    // object was created within:
    className =
    new Throwable().getStackTrace()[1].getClassName();
    testStream = new TestStream(className);
    public static List fileToList(String fname) {
    ArrayList list = new ArrayList();
    try {
    BufferedReader in =
    new BufferedReader(new FileReader(fname));
    try {
    String line;
    while((line = in.readLine()) != null) {
    if(fname.endsWith(".txt"))
    list.add(line);
    else
    list.add(new TestExpression(line));
    } finally {
    in.close();
    } catch (IOException e) {
    throw new RuntimeException(e);
    return list;
    public static List arrayToList(Object[] array) {
    List l = new ArrayList();
    for(int i = 0; i < array.length; i++) {
    if(array[i] instanceof TestExpression) {
    TestExpression re = (TestExpression)array;
    for(int j = 0; j < re.getNumber(); j++)
    l.add(re);
    } else {
    l.add(new TestExpression(array[i].toString()));
    return l;
    public void expect(Object[] exp, int flags) {
    if((flags & WAIT) != 0)
    while(testStream.numOfLines < exp.length) {
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) {
    throw new RuntimeException(e);
    List output = fileToList(className + "Output.txt");
    if((flags & IGNORE_ORDER) == IGNORE_ORDER)
    OutputVerifier.verifyIgnoreOrder(output, exp);
    else if((flags & AT_LEAST) == AT_LEAST)
    OutputVerifier.verifyAtLeast(output,
    arrayToList(exp));
    else
    OutputVerifier.verify(output, arrayToList(exp));
    // Clean up the output file - see c06:Detergent.java
    testStream.openOutputFile();
    public void expect(Object[] expected) {
    expect(expected, EXACT);
    public void expect(Object[] expectFirst,
    String fname, int flags) {
    List expected = fileToList(fname);
    for(int i = 0; i < expectFirst.length; i++)
    expected.add(i, expectFirst[i]);
    expect(expected.toArray(), flags);
    public void expect(Object[] expectFirst, String fname) {
    expect(expectFirst, fname, EXACT);
    public void expect(String fname) {
    expect(new Object[] {}, fname, EXACT);
    } ///:~

    What do you have in the C:\TIJCode\ directory? Does the directory structure mimic the package structure for the stuff you're importing?

  • Unable to compile "SerialDemo.java", many "cannot find symbols" errors

    I have all the correct files in their respective directory.
    comm.jar in jre\lib\bin,
    javax.comm.properties in jre\lib
    win32com.dll in jre\bin
    I extracted all the whole of SerialDemo into one folder and started compiling from there. But it doesn't work. I keep getting many "cannot find symbol" errors. They are usually referred to by:
    SerialParameters
    SerialConnection
    AlertDialog
    SerialConnectionException
    SerialDemo.java is not edited and was compiled directly. All of my files are in one folder (AlertDialog.java compiles fine and is in the same folder, etc)
    I was wondering what might be the cause of it. I'm currently using a Windows XP Service Pack 2, IBM P3 Laptop. I was reading "http://forum.java.sun.com/thread.jspa?threadID=674514&messageID=3941560"
    And I found out it works fine on Win2k OS. Why is this so? I'm getting the exact same error as he stated on his last post and I tried looking for a solution and decided to turn to you guys. I'd really appreciate some help, if any. Thanks in advance.

    I followed the PlatformSpecific. I realised that I
    added one for JRE when it wasn't required. The
    problem was solved.
    Thank you so much, the both of you. My stupid mistake
    caused quite a bit of havoc. I apologise.No need to apologise; The confusing part is that when you download
    a jre, that's just what your get: a jre, but when you download the jdk
    you not just get the jdk and the jre but you get a second jre with them,
    stored under the jdk directory.
    To the programmer that second jre is useless, it is used internally by
    the jdk tools.
    kind regards,
    Jos

  • Cannot find symbol error.. really stuck.

    I have a class named Rectangle.java. It is in a package "Geometry" together with Point.java and Line.java. But when I try to use Rectangle.java in my main program, MyRect.java, it gives me a "cannot find symbol" error, particularly the methods and sometimes the variables. I tried compiling just my Rectangle class and it compiled fine.. And I tried the Line and Point classes on another program and it works fine... well probably because the Line and Point classes are from a book(Ivor Horton's Beginning Java 2).. I am just starting out in Java. :)
    Rectangle.java
    package Geometry;
    public class Rectangle{
        public Point[] corner = new Point[4];
        public String name;
        public Rectangle(){
            corner[0].setPoints(0,0);
            corner[1].setPoints(1,0);
            corner[2].setPoints(0,1);
            corner[3].setPoints(1,1);
            name = new String("Unknown");
        public Rectangle(double point1_x,double point1_y,double point2_x, double point2_y, String Name){
            corner[0].setPoints(point1_x, point1_y);
            corner[3].setPoints(point2_x, point2_y);
            corner[1].setPoints(point2_x, point1_y);
            corner[2].setPoints(point1_x, point2_y);
            name = new String(Name);
        public Rectangle(final Rectangle oldRect, String Name){
            corner[0] = oldRect.corner[0];
            corner[3] = oldRect.corner[3];
            corner[1] = oldRect.corner[1];
            corner[2] = oldRect.corner[2];
            name = new String(Name);
        public double getWidth(){
            return corner[0].distance(corner[1]);
        public static void printRectangle(final Rectangle rect){
            for(int i= 0;i<4;i++){
                System.out.println("Corner"+(i+1)+" X: "+rect.corner.getX()+" Corner"+(i+1)+" Y: "+rect.corner[i].getY());
    System.out.println();
    public String toString(){
    return ("Name: "+name);
    }MyRect.java
    import Geometry.*;
    public class MyRect{
        public static void main(String[] args){
            Rectangle myRect = new Rectangle(0,0,2,1);
            Rectangle copyRect = new Rectangle(myRect);
            printRectangle(myRect);
            double width = myRect.getWidth();
    }and the errors:
    MyRect.java:4: cannot find symbol
    symbol  : constructor Rectangle(double,double,double,double,java.lang.String)
    location: class Rectangle
                    Rectangle myRect = new Rectangle(0.0,0.0,2.0,1.0,"My Rectangle")
                                       ^
    MyRect.java:9: cannot find symbol
    symbol  : variable name
    location: class Rectangle
                    System.out.println(myRect.name);
                                             ^
    2 errors

    Are you sure you have posted the whole content of MyRect.java
    import Geometry.*;
    public class MyRect{
        public static void main(String[] args){
            Rectangle myRect = new Rectangle(0,0,2,1);
            Rectangle copyRect = new Rectangle(myRect);
            printRectangle(myRect);
            double width = myRect.getWidth();
    }I don't see the following error line in the code you have given.
    MyRect.java:4: cannot find symbol
    symbol  : constructor Rectangle(double,double,double,double,java.lang.String)
    location: class Rectangle
                    Rectangle myRect = new Rectangle(0.0,0.0,2.0,1.0,"My Rectangle")
                                       ^
    MyRect.java:9: cannot find symbol
    symbol  : variable name
    location: class Rectangle
                    System.out.println(myRect.name);
                                             ^
    2 errors

  • Cannot find symbol error. don't know why

    Hello, I'm trying to write a button bean in the shape of a triangle but netbeans keeps throwing up a cannot find symbol error at my g.fillPolygon line. I've declared the number of sides and x and y coords.
    Any ideas as to why this is happening would be greatly appreciated.
    Here's the code:
    package trianglebutton;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    public class TriangleButtonBean extends JButton implements Serializable
    private TriangleButtonBean graphicPolygon;
    private Color buttonColour;
    private Color textColour;
    private String caption;
    private int sides = 3;
    private int size = 30;
    private int centerX = 100;
    private int centerY = 100;
         public TriangleButtonBean()
              super();
              setPreferredSize(new Dimension(50,50));
              setBorder(null);
              buttonColour = Color.red;
              textColour = Color.black;
              caption = "";
         public TriangleButtonBean(String acaption)
              super();
              setPreferredSize(new Dimension(50,50));
              setBorder(null);
              caption = acaption;
         public void paintComponent(Graphics g)
    String astring;
              super.paintComponent(g);
    g.setColor(buttonColour);
              int centerX = graphicPolygon.getCenterX(); //Invoking getCenterX method
              int centerY = graphicPolygon.getCenterY(); //Invoking getCenterY method
              //int Xcoordinates [] = graphicPolygon.getPolygonXCoordinates(sides,size);
              //int Ycoordinates [] = graphicPolygon.getPolygonYCoordinates(sides,size);
    g.drawPolygon(centerX,centerY, sides); //Draw polygon using xcoord,ycoord and number of sides
              g.fillPolygon(centerX,centerY, sides); //Fill poly
              g.setColor(textColour);
              if (caption.length() > 1)
                   astring = caption.substring(0,1);
              else
                   astring = caption;
              g.drawString(astring,22,27);
         public void setButtonColour(Color acolour)
              buttonColour = acolour;
              repaint();
         public Color getButtonColour()
              return buttonColour;
         public void setTextColour(Color acolour)
              textColour = acolour;
              repaint();
         public Color getTextColour()
              return textColour;
         public void setCaption(String acaption)
              caption = acaption;
              repaint();
         public String getCaption()
              return caption;
    // public void setCenterX(int xcoords)
    // centerX = xcoords;
    public int getCenterX()
    return centerX;
    // public void setCenterY(int ycoords)
    // centerY = ycoords;
    public int getCenterY()
    return centerY;
    public static void main(String[] args){
    TriangleButtonBean agui = new TriangleButtonBean();
    } // End of class

    Please READ, STUDY, and UNDERSTAND the error messages, they are telling you exactly what the problem is:
    . . .\TriangleButtonBean.java:56: cannot find symbol
    symbol  : method drawPolygon(int,int,int)
    location: class java.awt.Graphics
    g.drawPolygon(centerX,centerY, sides); //Draw polygon using xcoord,ycoord and number of sides
    ^
    . . .\TriangleButtonBean.java:57: cannot find symbol
    symbol  : method fillPolygon(int,int,int)
    location: class java.awt.Graphics
    g.fillPolygon(centerX,centerY, sides); //Fill poly
    ^
    2 errors
    Process javac exited with code 1In both cases the messages ar telling you that the methods
    drawPolygon(int,int,int)
    method fillPolygon(int,int,int)
    can't be found in java.awt.Graphics
    And if you look at the documentation, you see that is indeed the problem - the first two arguments are int arrrays, not int.
    Fix the method signature or use something else.

  • Cannot find symbol error -- array fill from text file

    When I compile my program I receive a cannot find symbol error for the variable ayears. I thought this snippet would fill the array ayears that could be accessed later in the program but I am getting the error message from my buildGUI() class. What could I have done wrong?
    (my file options.txt contains data separated by a comma and a space)
    public void getOption(){
         InputStream istream;
         File options = new File("options.txt");
         istream = new FileInputStream(options);
         try {
                               StringBuffer sbuff = new StringBuffer();
                               BufferedReader inbuff = new
    BufferedReader(new FileReader(options));
                               String line = "";
                               while((line = inbuff.readLine()) != null) {
                               System.out.println(line); 
              sbuff.append(line);
                               inbuff.close();
                              String fileData = sbuff.toString();
              String[] splitData = fileData.split(", ");
              String[] ayears = new String[splitData.length];
         catch(Exception e){
         JOptionPane.showMessageDialog(null,
         "Could not find specified file", "Error Message",
         JOptionPane.ERROR_MESSAGE);
    }

    Okay -- that helped. I've avoided that error -- now on to the next one, why won't my array fill? It's going to be a long night.
    Thanks for the help.

  • "Cannot find Symbol" error message

    I have a "cannot find symbol" error message on line 5 below in
    the driver class.
    Thank you for your assistance
    1 public class GameLauncher
    2 {
    3  public static void main(String[] args)
    4 {
    5   GuessGame game = new GuessGame();
    6   game.startGame();
    7 }
    8}
    public class GuessGame
      public void startGame()
      Player p1;
      Player p2;
      Player p3;
      int guessp1 = 0;
      int guessp2 = 0;
      int guessp3 = 0;
      boolean p1isRight = false;
      boolean p2isRight = false;
      boolean p3isRight = false;
      int targetNumber = (int) (Math.random() * 10);
      System.out.println(" I'm thinking of a number between 0 and 9....");
      while(true)
        p1.guess();
        p2.guess();
        p3.guess();
        guessp1 = p1.number;
        System.out.println("Player one guessed " + guessp1);
        guessp2 = p2.number;
        System.out.println("Player two guessed " + guessp2);
        guessp3 = p3.number;
        System.out.println("Player three guessed " + guessp3);
        if (guessp1 == targetNumber)
          p1isRight = true;
        if (guessp2 == targetNumber)
          p2isRight = true;
        if (guessp3 == targetNumber)
          p3isRight = true;
        if ( p1isRight || p2isRight || p3isRight)
          System.out.println("We have a winner ! ");
          System.out.println("Player one got it right? " + p1isRight);
          System.out.println("Player two got it right? " + p2isRight);
          System.out.println("Player three got it right? " + p3isRight);
          System.out.println("Game is over ! ");
          break; //game is over so break out of loop
        else
          //we must keep going because no one guessed the number !
          System.out.println(" Players will have to try again ! ");
        } // end of if/else
      } // end of loop
    } // end of startGame() method
    } //end of class
    public class Player
      int number = 0;   // the guess is stored here
      public void guess()
        System.out.println(" I'm guessing " + number);
    ---------------------------------------------------------------  

    Thank you . You were right . I didn't set up the classes correctly.
    I corrected a few other errors and the program runs ok !
    Below is the corrected code and the output
    public class GameLauncher
      public static void main(String[] args)
       GuessGame game = new GuessGame();
       game.startGame();
    /* One possible set of output is
    I'm thinking of a number between 0 and 3....
    I'm guessing 1
    I'm guessing 3
    I'm guessing 0
    Player one guessed 1
    Player two guessed 3
    Player three guessed 0
    We have a winner !
    Player one got it right? true
    Player two got it right? false
    Player three got it right? false
    Game is over !
    public class Player
      int number = 0;   // the guess is stored here
      public void guess()
        number = (int)(Math.random() * 4);
        System.out.println(" I'm guessing " + number);
    public class GuessGame
      public void startGame()
        int x = 0;
      Player p1 = new Player();
      Player p2 = new Player();
      Player p3 = new Player();
      int guessp1 = 0;
      int guessp2 = 0;
      int guessp3 = 0;
      boolean p1isRight = false;
      boolean p2isRight = false;
      boolean p3isRight = false;
      int targetNumber = (int) (Math.random() * 4);
      System.out.println("\n I'm thinking of a number between 0 and 3....\n");
      while(x <5)
        p1.guess();
        p2.guess();
        p3.guess();
        guessp1 = p1.number;
        System.out.println("\nPlayer one guessed " + guessp1);
        guessp2 = p2.number;
        System.out.println("Player two guessed " + guessp2);
        guessp3 = p3.number;
        System.out.println("Player three guessed " + guessp3);
        if (guessp1 == targetNumber)
          p1isRight = true;
        if (guessp2 == targetNumber)
          p2isRight = true;
        if (guessp3 == targetNumber)
          p3isRight = true;
        if ( p1isRight || p2isRight || p3isRight)
          System.out.println("\nWe have a winner ! ");
          System.out.println("Player one got it right? " + p1isRight);
          System.out.println("Player two got it right? " + p2isRight);
          System.out.println("Player three got it right? " + p3isRight);
          System.out.println("Game is over ! ");
          break; //game is over so break out of loop
        else
          //we must keep going because no one guessed the number !
          System.out.println(" Players will have to try again ! ");
        } // end of if/else
        x = x + 1;
      } // end of loop
    } // end of startGame() method
    } //end of class 

  • Need help with classes

    I''ve just started out with Java and I need help with my latest program.
    The program looks someting like this:
    public class MultiServer {
       public static void main(Straing[] args) {
          ServerGUI GUI = new ServerGUI();
    public class ServerGUI extends JFrame implements ActionListener {
       private TextArea textArea;
       public ServerGUI() {
          //setting up the JFrame and stuff like that
       public void actionPerformed(ActionEvent event) {
          if(button == addButton) {
             addGUI add = new addGUI();
    public class addGUI extends JFrame implements ActionListener {
        private TextField t1 = new TextField(25);
        public addGUI() {
          //setting up the JFrame and stuff like that
       public void actionPerformed(ActionEvent event) {
          if(button == printButton) {
             textArea.append("THIS DOES NOT WORK!");
    }   The problem is as follows: I want to be able to write text in the textArea in class ServerGUI from the class addGUI, but I can't. I hope you understand what I mean.
    How is this fixed? Please help me!

    public void actionPerformed(ActionEvent event) {
          if(button == addButton) {
             addGUI add = new addGUI(textArea);
    public class addGUI extends JFrame implements ActionListener {
        private TextArea textArea;
        public addGUI(TextArea textArea) {
            this.textArea = textArea;
        }/Kaj

Maybe you are looking for