Java cannot find symbol [Color type]

* Parked car class
* class properties are
* - Car Color
* - Car Model
* - Car Make
* - License Number
* - Number of minutes car has been parked
public class ParkedCar {
// Field declarations for class ParkedCar
// declare color datatype (enum)
Color CarColor;
String CarModel,
CarMake,
LicenseNumber;
double TimeParkedMinutes;
public ParkedCar() {
CarColor = Color.NOTSPECIFIED;
CarModel = "NOT SPECIFIED";
CarMake = "NOT SPECIFIED";
LicenseNumber = "NOT SPECIFIED";
TimeParkedMinutes = 0.0;
} // end no arg constructor method for ParkedCar class
public ParkedCar(Color parkedColor, String parkedModel, String parkedMake, String parkedLicense, double parkedMinutes) {
CarColor = parkedColor;
CarModel = parkedModel;
CarMake = parkedMake;
LicenseNumber = parkedLicense;
TimeParkedMinutes = parkedMinutes;
} // end constructor ParkedCar
public Color getColor() {
return CarColor;
public String getModel() {
return CarModel;
public String getMake() {
return CarMake;
public String getLicenseNumber() {
return LicenseNumber;
public double getTimeParkedMinutes() {
return TimeParkedMinutes;
} // end class ParkedCar
I keep getting this compilation error
ParkedCar.java:21: cannot find symbol
symbol  : class Color
location: class Color.ParkedCar
Color CarColor;
The enumerated data type Color is declared within a separate class file. This code will compile when Color is defined within this class. Seems that enums are somewhat of a strange breed. Any ideas?
Last edited by estex198 (2009-04-06 17:07:43)

found some example code. I'm definately doing something wrong here. Do I need an import statement somewhere? I found some example code on a tutorial site. The enumerated data type Days is only accessible to members of EnumTest if its declaration is within the class EnumTest (as opposed to storing the enum declaration in its own .java file.
public class EnumTest {
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
Day day;
public EnumTest(Day day) {
this.day = day;
public void tellItLikeItIs() {
switch (day) {
case MONDAY: System.out.println("Mondays are bad.");
break;
case FRIDAY: System.out.println("Fridays are better.");
break;
case SATURDAY:
case SUNDAY: System.out.println("Weekends are best.");
break;
default: System.out.println("Midweek days are so-so.");
break;
public static void main(String[] args) {
EnumTest firstDay = new EnumTest(Day.MONDAY);
firstDay.tellItLikeItIs();
EnumTest thirdDay = new EnumTest(Day.WEDNESDAY);
thirdDay.tellItLikeItIs();
EnumTest fifthDay = new EnumTest(Day.FRIDAY);
fifthDay.tellItLikeItIs();
EnumTest sixthDay = new EnumTest(Day.SATURDAY);
sixthDay.tellItLikeItIs();
EnumTest seventhDay = new EnumTest(Day.SUNDAY);
seventhDay.tellItLikeItIs();
If I were to store the enum declaration in its own file then it should look something like this(?):
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
Thanks for your time.

Similar Messages

  • Java Error : cannot find symbol , symbol : class (jdk 1.6.0)

    Dear All,
    Please help me.
    I am running javac from a .bat file and i set the classpath in the bat file as follows.
    echo on
    :start
    set classpath = "C:\Program Files\Java\jdk1.6.0\bin;"
    set classpath = "C:\Program Files\Java\jdk1.6.0\jre\..\lib\tools.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\i18n.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0\jre\classes;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\ldapsec.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\mysql-connector-java-5.0.0-beta-bin.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\sunjce_provider.jar; C:\Program Files\Java\jdk1.6.0\ideset\system;C:\Program Files\Java\jdk1.6.0\ideset\system;C:\Program Files\Java\jdk1.6.0\studio\system;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\j2ee-1.3.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\jaas-1.0.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\autoload\activation.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\jms-1.0.2b.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\jta-spec1_0_1.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\autoload\mail.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\AbsoluteLayout.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\sql.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\rowset.jar;C:\Program Files\Java\jdk1.6.0\studio\lib\ext\jdbc20x.zip;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\servlet-2.3.jar;C:\Program Files\Java\jdk1.6.0\studio\beans\TimerBean.jar;c:\Program Files\Java\jdk1.6.0\ideset\tomcat401_base;C:\sms\com\;"
    cd C:\sms
    javac mainP.java
    pause
    i have few class files which are inherited to the main program using ' import com.Connection; '
    i am getting errors like
    mainP.java:482: cannot find symbol
    symbol : class Connection
    location: class mainP
    Connection connection = new Connection(ipAddress, port);
    I think it is because of some classpath error.
    please advice me.......
    Viju

    Actually, you have NO CLUE what he's trying to doActually he said what he is trying to do in his posting. It's no mystery. But that's all the information that's available. If you know something that isn't posted here why not say so?
    Your reply was a snide, rude, "You're stupid for doing it that way" answerMy reply was neither snide nor rude and implied none of what you impute to it. It was a proper and constructive suggestion. You are entitled to disagree with it, but that doesn't justify this immoderate outburst.
    Bottom line is, you chose to be nastyBottom line is you're just making this up. You are imputing motives to me without evidence. Don't do that.
    You are the type of person that makes searching forums and posting questions for assistance a near waste of time.I doubt that you'll find many regulars here that would agree with that assertion. When you have made over 16,000 posts here over ten years as I have, come back and we'll discuss it some more.
    Go back to grade school and ...I suggest you try it yourself. You're not adding anything except noise to the discussion. Try curbing your temper, and while you're at it have a good look at the Code of Conduct for these forums. You're verging on personal abuse here.
    And, additionally, I've used ANT in the past. Batch files are FAR AND AWAY easier to set up.In your opinion. I disagree entirely, and I have eleven years' experience with Java to back it up.
    As for CLASSPATH, I haven't done anything about setting it beyond installing the JDK since about 1999, and it has a dot in it as we speak.

  • Java:3: cannot find symbol

    i'm learning java
    but when i do a java projram i got a error
    hare is that
    Test1.java:3: cannot find symbol
    symbol : variable Out
    location: class java.lang.System
    System.Out.Println("john");
    ^
    1 error
    i got this error. i see "." this symbol
    then what should i do ?

    Java is case-sensitive. Don't type "Out" and "Println" when you're supposed to type "out" and "println".
    Try this:
    System.out.println("john");

  • Java Studio Enterprise 8.1 and jdk1.6 - cannot find symbol

    Hi,
    I am using subj. The problem I have is that I declared 2-3 classes with methods in one package. I made an object of the class and use intellisense to navigate to the method I need but when I try to compile the code I have "cannot find symbol" error on the method I intellisensed to. It seems to me that it is IDE problem.
    Does anyone know how to work around it?
    The code is below, in case you are interested.
    package webservice;
    import java.io.*;
    public class Main {
    /** Creates a new instance of Main */
    public Main() {
    * @param args the command line arguments
    public static void main(String[] args) {
    String filename = null;
    String timestamp = null;
    try {
    Q q = new Q();
    timestamp = "2007-06-01";
    QList ql = q.getList(timestamp);
    System.out.println("--------------Ok-------------");
    catch(Exception e) {
    System.out.println("An Exception thrown in Main(). e = "+e.toString());
    package webservice;
    public class Q {
    public Q() {
    public QList getList(String timestamp) {
    QList result = null;
    return result;
    Thanks,
    Dmitry

    Thanks for that Kris.
    I found the root of my problem. In this example I used a remote webservice to retrieve some data. It happened to be that the generated class file from wsdl and my custom class had the same name.
    So, instead of reporting as ambiguous definition error the ide picked up the wrong class and did not find the method I intended to use.
    Hopefully it will help someone else having the same problem.
    Dmitry

  • Java.util.concurrent.LinkedBlockingDeque: cannot find symbol

    Hello,
    I'm trying to use an existing java code into a JavaFX application. To do this, I copied all my sources into the fx project in Netbeans and I linked the needed libraries, but when I tried to compile all this, I got the following message:
    "cannot find symbol
    symbol : class LinkedBlockingDeque
    location: package java.util.concurrent
    import java.util.concurrent.LinkedBlockingDeque;"
    the problem is at that line: import java.util.concurrent.LinkedBlockingDeque;
    This is a native java class. Is it not supported in JavaFx? Is not java fully compatible with Fx? What's happening?
    Thank you in advance

    Please, create an issue on it with the detailed comments: [http://www.netbeans.org/issues/enter_bug.cgi?component=javafx|http://www.netbeans.org/issues/enter_bug.cgi?component=javafx]

  • Java code Cannot find symbol problem

    I'm triing to compile three classes they are in the same directory yet it still says Cannot find symbol I can't find any thing in the spelling...
    file #1
    package banking;
    import java.util.*;
    public class Bank {
         private ArrayList<Account> accounts = new ArrayList<Account>();
         private int numOfCust;
         public void addCustomer(String fName, String lName){
              numOfCust += 1;
              accounts.add(Customer(fName, lName));
         public int getNumOfCustomers(){
              return numOfCust;
         public Account getCustomer(int custNum){
              return accounts.get(custNum);
    }Next Class used in above:
    package banking;
    public class Account {
         private double balance;
         public Account(double init_balance){
              balance = init_balance;
         public double getBalance(){
              return balance;
         public boolean deposit(double amount){
              if (amount < 0)
                   return false;
              else
                   balance += amount;
                   return true;
         public boolean withdraw(double amount){
              if (balance < amount)
                   return false;
              else
                   balance -= amount;
                   return true;
    }The last class:
    package banking;
    public class Customer {
         private String firstName;
         private String lastName;
         private Account account;
         public Customer(String fName, String lName){
              firstName = fName;
              lastName = lName;
         public String getFirstName(){
              return firstName;
         public String getLastName(){
              return lastName;
         public Account getAccount(){
              return account;
         public Account setAccount(Account acct){
              account = acct;
              return account;
    }

    here are the errors it gives..
    it is an assignment in a java class..
    OO-Programming methods..
    C:\JavaProgs\banking>javac Bank.java
    Bank.java:8: cannot find symbol
    symbol : class Account
    location: class banking.Bank
    private ArrayList<Account> accounts = new ArrayList<Account>();
    ^
    Bank.java:20: cannot find symbol
    symbol : class Account
    location: class banking.Bank
    public Account getCustomer(int custNum){
    ^
    Bank.java:8: cannot find symbol
    symbol : class Account
    location: class banking.Bank
    private ArrayList<Account> accounts = new ArrayList<Account>();
    ^
    Bank.java:13: cannot find symbol
    symbol : method Customer(java.lang.String,java.lang.String)
    location: class banking.Bank
    accounts.add(Customer(fName, lName));
    ^
    4 errors

  • Max3.java:17: cannot find symbol

    Hi guys,
    Need some help here..
    This is my code:
    import java.util.Scanner;
    import static java.lang.Math.*;
    public class Max3{
         public static void main (String[] args)     {
         Scanner kb = new Scanner(System.in);
         System.out.print ("Enter 1st number:");
         int first = kb.nextInt();
         System.out.print ("Enter 2nd number:");
         int second = kb.nextInt();
         System.out.print ("Enter 3rd number:");
         int third = kb.nextInt();
         System.out.println (Math.max(first,second,third));
    ===================================================================
    This is the error im getting :
    Max3.java:17: cannot find symbol
    symbol : method max(int,int,int)
    location: class java.lang.Math
    System.out.println (Math.max(first,second,third));
    ^
    1 error
    ====================================================================
    Do i need to import the math? i read from somewhere that Math class is contained in the Java.lang package, and we therefore don't have to import it ...

    I tried again, same error.
    Edited Maths.max to only max
    ========================================
    import java.util.Scanner;
    import static java.lang.Math.*;
    public class Max3{
         public static void main (String[] args)     {
         Scanner kb = new Scanner(System.in);
         System.out.print ("Enter 1st number:");
         int first = kb.nextInt();
         System.out.print ("Enter 2nd number:");
         int second = kb.nextInt();
         System.out.print ("Enter 3rd number:");
         int third = kb.nextInt();
         System.out.println (max(first,second,third));
    =================================================
    Error:
    C:\kenny>javac Max3.java
    Max3.java:17: cannot find symbol
    symbol : method max(int,int,int)
    location: class Max3
    System.out.println (max(first,second,third));
    ^
    1 error
    Thanks for spending some time on this!

  • "Simon2.java:37: cannot find symbol

    Im coming up with this error. Does anyone know what I'm missing.
    Thankyou for any response
    "Simon2.java:37: cannot find symbol
    symbol : method getPane()
    location: class Simon2
    Container pane = getPane();
    ^
    1 error"
    public Component createComponents(){
    JButton button;
    Container pane = getPane();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    pane.setLayout(gridbag);
    button = new JButton("Holy Shit!");
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(button, c);
    pane.add(button);
    return pane;
    button.setMnemonic(KeyEvent.VK_I);
    button.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    }

    Here's all the code so far, where have I gone wrong
    Simon2.java:37: cannot find symbol
    symbol : method getContentPane()
    location: class Simon2
    Container contentPane = getContentPane();
    ^
    1 error
    mport javax.swing.*;
    import javax.swing.UIManager;
    import java.awt.*;
    import java.awt.event.*;
    import com.l2fprod.gui.plaf.skin.*;
    import javax.swing.JButton;
    public class Simon2 {
    public static void main(String[] args) {
    try {
    Skin theSkinToUse = SkinLookAndFeel.loadThemePack("chaNinja-Bluethemepack.zip");
    SkinLookAndFeel.setSkin(theSkinToUse);
    UIManager.setLookAndFeel(new SkinLookAndFeel());
    } catch (Exception e){ }
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame fr = new JFrame("Simon2");
    Simon2 app = new Simon2();
    Component contents = app.createComponents();
    fr.getContentPane().add(contents, BorderLayout.CENTER);
    fr.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    fr.setTitle("AnimalDance");
    fr.setSize(500, 200);
    fr.setVisible(true);}
    public Component createComponents(){
    JButton button;
    Container contentPane = getContentPane();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    contentPane.setLayout(gridbag);
    button = new JButton("Holy birds!");
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(button, c);
    contentPane.add(button);
    return contentPane;
    button.setMnemonic(KeyEvent.VK_I);
    button.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    }

  • 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

  • Another cannot find symbol error (DiveLog)

    Hi I am fairly new to java and I decided to try the tutorial DiveLog. I followed the instructions, however when I try to compile it, not with the DOS command, I keep getting an error stating that, Cannot find symbol class ..... The errors keep recurring at the tabbedPane.addTab(".....",
    package DiveLog;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class DiveLog
    { // Opens class
    public JTabbedPane tabbedPane;
    public JFrame dlframe;
    public DiveLog()
    { // Opens contructor
    //Create a frame object to add the application
    //GUI components to.
    dlframe = new JFrame("A Java(TM) Technology Dive Log");
    // Closes from title bar
    //and from menu
    dlframe.addWindowListener(new WindowAdapter()
    { // Opens addWindowListener method
    public void windowClosing(WindowEvent e)
    { // Opens windowClosing method
    System.exit(0);
    } // Closes windowClosing method
    }); // Closes addWindowListener method
    // Tabbed pane with panels for Jcomponents
    tabbedPane = new JTabbedPane(SwingConstants.LEFT);
    tabbedPane.setBackground(Color.blue);
    tabbedPane.setForeground(Color.white);
    //A method that adds individual tabs to the
    //tabbedpane object.
    populateTabbedPane();
    //Calls the method that builds the menu
    buildMenu();
    dlframe.getContentPane().add(tabbedPane);
    dlframe.pack();
    dlframe.setSize(765, 690);
    dlframe.setBackground(Color.white);
    dlframe.setVisible(true);
    } //Ends the constructor
    private void populateTabbedPane()
    { // Opens populateTabbedPane method
    // Create tabs with titles
    tabbedPane.addTab("Welcome",
    *               null,*
    *               new Welcome(),*
    *               "Welcome to the Dive Log");*
    *     tabbedPane.addTab("Diver Data",*
    *               null,*
    *               new Diver(),*
    *               "Click here to enter diver data");*
    *     tabbedPane.addTab("Log Dives",*
    *               null,*
    *               new Dives(),*
    *               "Click here to enter dives");*
    *     tabbedPane.addTab("Statistics",*
    *               null,*
    *               new Statistics(),*
    *               "Click here to calculate dive statistics");*
    *     tabbedPane.addTab("Favorite Web Site",*
    *               null,*
    *               new WebSite(),*
    *               "Click here to see a web site");*
    *     tabbedPane.addTab("Resources",*
    *               null,*
    *               new Resources(),*
    *               "Click here to see a list of resources");*
    *          } //Ends populateTabbedPane method*
    private void buildMenu()
    { // Opens buildMenu method
    JMenuBar mb = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem item = new JMenuItem("Exit");
    //Closes the application from the Exit
    //menu item.
    item.addActionListener(new ActionListener()
    { // Opens addActionListener method
    public void actionPerformed(ActionEvent e)
    { // Opens actionPerformed method
    System.exit(0);
    } // Closes actionPerformed method
    }); // Closes addActionListener method
    menu.add(item);
    mb.add(menu);
    dlframe.setJMenuBar(mb);
    } //Ends the buildMenu method
    } //Ends class
    If you could help me, please explain it into terms that I would understand as I am still new to the entire language. Thanks

    cannot find symbol: whatever class or method signature or variable you use was never declared. It's as simple as that. Make sure that the names are correct; if a class is missing (thanks a bunch for omitting the relevant part of the error message :p), ensure the compiled .class file is in the classpath, if a method isn't found make sure that the arguments are provided exactly in the same order, number and type as the method declaration declares, and if a variable is missing make sure that you actually declared it.
    Learn about code tags when posting code next time, by the way.

  • Cannot find Symbol :class CLOB

    Hi,
    I am using JDK1.5.0_06 and Oracle8.1.7.
    When i compile java program I am getting the following error
    cannot find symbol
    symbol : class CLOB
    I have added classes12.zip into classpath.
    Can anybody tell me why this errpr comes? Is there any other files instead of classes12.zip to be added (since its JDK1.5 version? )
    Thanks in advance
    neema

    you have mentioned about the class "studentList" but that class is not to be found in the code you have pasted. its instead "ListTest". And the "menu" function seems to b a part of "ListTest" class. Can you provide the structure of the classes "studentList" and "Student" so that the problem can be more clearly understood?
    also you are using the variable "Stdin" in the line int choice = Stdin.readInteger(); where as you have not declared this variable.
    in the "switch" statement you are calling two different functions for the same case "3" where as it should be "case 3" and "case 4" respectively.
    in the "main" you are calling the "menu" function without any parameter while you actually want to pass argument of type "studentList".

  • Inheritance - Cannot find Symbol

    Hello!
    After many hours of searching for the answer, i have decided to brave getting a grilling for asking something trivial.
    I'm creatating a system and so far the problem i am having is inheritance.
    The superclass compiles fine, no problems:
    package Boats;
    public abstract class Boat
         protected String name;
         protected int price;
         protected int id;          
         protected String type;          
         protected boolean hire;
         public boat(int boatID, String boatName, int cost, String boatType)
            name = boatName;
              price = cost;
              id = boatID;
              type = boatType;
            hire = false;
    }however, the subclass of pedal boat won't compile:
    package Boats;
    public abstract class PedalBoat extends Boat
         private String colour;
        public PedalBoat(int id, String boatName, int cost, String boatType, String c)
            super(id, boatName, cost, boatType);
              colour = c;
            super.hire = false;
    }both of these class files are in the same folder 'Boats', but when i compile PedalBoat, the following message is displayed:
    "PedalBoat.java:2: cannot find symbol
    symbol: class Boat
    public abstract class PedalBoat extends Boat
    ^
    Any thoughts or help or links to anywhere that has answered this before?
    Thanks!

    You'll want the following directory structure. The C:\projects part is arbitrary. It's what comes after it that matters.
    C:\projects\Boats\Boat.java
    C:\projects\Boats\PedalBoat.javaThen, CD to C:\projects, and execute
    javac -cp . Boats/*.javaAs a side note, to go with the flow convention-wise, I'd suggest renaming your Boats package to boats. Package names are conventionally all lowercase.
    [Javapedia: Classpath|http://wiki.java.net/bin/view/Javapedia/ClassPath]
    [How Classes are Found|http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html]
    [Setting the class path (Windows)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html]
    [Setting the class path (Solaris/Linux)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html]
    [Understanding the Java ClassLoader|http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html]
    java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
    javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

  • "cannot find symbol" errormessage

    Hello
    I want to keep my ArrayList information private so I declared:
    private ArrayList<Integer> locationAddress;I created the ArrayList object in the constructor     public SimpleDotCom()
               locationAddress = new ArrayList<Integer>();
          }I was using a remove() method available with the ArrayList class.
    I decided to encapsulate the remove() method in
      public void removeLocationIndex(int index)
            locationAddress.remove(index);
          }but when I try to call the method by saying:   locationAddress.removeLocationIndex(index); I get an error message that says:
    cannot find symbol; symbol : method removeLocationIndex(int), location: class java.util.ArrayList<java.lang.Integer> at line 47
    Below is the class.
    Thank you for your assistance  public class SimpleDotCom
           private ArrayList<Integer> locationAddress;
         public SimpleDotCom()
               locationAddress = new ArrayList<Integer>();
          public void storeLocationAddress(int location)
            locationAddress.add(location);
          public void removeLocationIndex(int index)
            locationAddress.remove(index);
          static final int  INCORRECTGUESS = 2;
          static final int GOODGUESS = 1 ;
          static final int WIN = 0 ;
         public int checkIfGuessIsCorrect(int userGuess)
            int result = INCORRECTGUESS;
          /* find out if the user guess is in the ArrayList
          by asking for it's index. If it's not in the list,
          then indexOf() returns a -1 */
          int index = locationAddress.indexOf(userGuess);
          if (index == -1)
              result = INCORRECTGUESS;
              System.out.print(" The result is a " + result + "... an Incorrect Guess !");
          if(index >= 0)
            /* if the index is zero or greater, it's in the list
            so remove it */
            locationAddress.removeLocationIndex(index);
            /* if the list isEmpty() then
               that was the "WINning" ing guess ! */
            if(locationAddress.isEmpty())
              result = WIN;
              System.out.print("  you WIN ! ");
            else
              result = GOODGUESS;    // 1 indicates a "hit"
              System.out.print("  The result is a  " + result + " a GOOD GUESS");
          } // end outer if
          return result;
        }//end method
      } // end class

    locationAddress is of type ArrayList. ArrayList doesn't have a method called removeLocationIndex(). You can call that method on an object of type SimpleDotCom.
    In a member method (such as checkIfGuessIsCorrect()) you can call this.removeLocationIndex() or simply removeLocationIndex() - the "this." is implicit. Which you prefer is up to you - some people see an explicit "this." as improving readability in some cases, some feel the extra typing is a sign of a newbie.

  • 5 Errors Left: "Cannot find symbol variable "

    I think I have almost completed my error fixing but I cannot seem to figure out how to fix these last few errors I have.
    Here are my errors:
    --------------------Configuration: MadrigalRPA6 - JDK version 1.6.0_02 <Default> - <Default>--------------------
    E:\MadrigalR\MadrigalRPA6\src\MadrigalRPA6.java:113: cannot find symbol
    symbol : variable size
    location: class ServicesArray
    servicesArray = new PetService[size];
    ^
    E:\MadrigalR\MadrigalRPA6\src\MadrigalRPA6.java:115: cannot find symbol
    symbol : variable io
    location: class ServicesArray
    int size = io.readInt("How many services do you have to enter?");
    ^
    E:\MadrigalR\MadrigalRPA6\src\MadrigalRPA6.java:123: cannot find symbol
    symbol : variable number
    location: class ServicesArray
    for(int i = 0; i < number; ++i)
    ^
    E:\MadrigalR\MadrigalRPA6\src\MadrigalRPA6.java:135: cannot find symbol
    symbol : variable number
    location: class ServicesArray
    for(int i = 0; i < number; ++i)
    ^
    E:\MadrigalR\MadrigalRPA6\src\MadrigalRPA6.java:144: cannot find symbol
    symbol : variable io
    location: class ServicesArray
    io.writeInfo(info);
    ^
    5 errors
    Process completed.
    * @(#)MadrigalRPA6.java
    * MadrigalRPA6 application
    * @author
    * @version 1.00 2007/11/5
    *     Program Purpose: This program is designed to store available services for
    *  Dr. Doolittle's Mobile Pet Clinic.
    import staugIO.StaugIO;
    //DECLARE PET SERVICES CLASS
    class PetService
    private String ServiceCode = " ";
    private String ServiceName = " ";
    private String ServiceDescription = " ";
    private String ServiceType = " ";
    private double price = 0.00;
    private StaugIO io = new StaugIO();
    //CONSTRUCTOR
    public PetService()
    //END CONSTRUCTOR
    //SET PET SERVICES NAME
    public void setServiceCode()
         ServiceCode = io.readString("Enter the service code");
    }//END setServiceCode()
    //SET SERVICE NAME
    public void setServiceName()
         ServiceName = io.readString("Enter the service name");
    }//END setServiceName()
    //SET SERVICE DESCRIPTION
    public void setServiceDescription()
         ServiceDescription = io.readString("Enter the service description");
    }//END setServiceDescription
    //SET SERVICE TYPE
    public void setServiceType()
         ServiceType = io.readString("Enter the service type");
    }//END setServiceType()
    //SET SERVICE PRICE
    public void setPrice()
         price = io.readDouble("Enter the service price");
    }//END setPrice()
    //GET PET SERVICE NAME
    public String getServiceCode()
         return ServiceCode;
    }//END getServiceCode()
    //GET SERVICE NAME
    public String getServiceName()
         return ServiceName;
    }//END getServiceName()
    //GET SERVICE DESCRIPTION
    public String getServiceDescription()
         return ServiceDescription;
    }//END getServiceDescription
    //GET SERVICE TYPE
    public String getServiceType()
         return ServiceType;
    }//END getServiceType
    //GET SERVICE PRICE
    public double getPrice()
         return price;
    }//END getPrice
    }//END PetService CLASS
    class ServicesArray
         PetService[] servicesArray;  // Code the reference to the null array.
    //CONSTRUCTOR
    public ServicesArray()
    //END CONSTRUCTOR     
    public void getSize()
         servicesArray = new PetService[size];     *////////ERROR HERE*
    //READ NUMBER OF SERVICES TO STORE
    int size = io.readInt("How many services do you have to enter?"); *///////ERROR HERE TOO*
    //DYNAMICALLY DEFINE ARRAY OF PET SERVICE OBJECTS
    PetService services[] = new PetService[size];
    //DEFINE PET SERVICE OBJECTS AND FILL ARRAY OF OBJECTS WITH PET SERVICE DATA
    for(int i = 0; i < number; ++i) */////////////ERROR HERE ASWELL*
    services[i] = new PetService();
    services.setServiceCode();
    services[i].setServiceName();
    services[i].setServiceDescription();
    services[i].setServiceType();
    services[i].setPrice();
    }//END FOR
    //BUILD OUTPUT STRING FROM ARRAY OF PET SERVICE OBJECTS
    //AND DISPLAY PET SERVICES ONE AT A TIME
    for(int i = 0; i < number; ++i) *////////HMM WOW THIS DOESN'T SURPRISE ME THAT I HAVE ANOTHER ERROR*
         String info = "PET SERVICE " + (i+1) + " DATA\n";
              info += "\nSERVICE CODE: " + services[i].getServiceCode() + "\n"
                   + "SERVICE: " + services[i].getServiceName() + "\n"
                   + "DESC: " + services[i].getServiceDescription() + "\n"
                   + "TYPE: " + services[i].getServiceType() + "\n"
                   + "PRICE: " + services[i].getPrice() + "\n";
    //DISPLAY PET SERVICE DATA
         io.writeInfo(info); *////////////ERROR HERE AS WELL*
    }//END FOR
    }//END getSize()
    }//END ServicesArray CLASS
    public class MadrigalRPA6
    public static void main(String[]args)
    PetService service = new PetService();
    }//END main()
    }//END MADRIGALRPA6 CLASS

    wow i simply added the
    private StaugIO io = new StaugIO();
    into my ServicesArray class and i got the process completed with no errors, thats awesome but what doesnt make sense is this summary of this assignment that i have:
    Code a program that will store available services for Dr. Doolittle's Mobile Pet Clinic. Let the user determine the size of the array. Once the array has been populated with service information, display the contents of the array one at a time in separate GUI windows. Screen capture your output to a Word file and submit it with everything else. Use the code on pp 365-367 in the textbook to help you. Assume that the spacing is always double after a period and colon. You may limit your array size to no more than 3 as indicated by the sample output below. Use the sample output to test your array.
    PET SERVICE NO. 1
    SERVICE CODE: DG-2478
    SERVICE: Dog Group I
    DESC: DHLPP, Corona, Bordetella, Rabies
    TYPE: Vaccine
    PRICE: $47.50
    PET SERVICE NO. 2
    SERVICE CODE: FL-3182
    SERVICE: Feline Group I
    DESC: FVRCP, FeLV, Rabies
    TYPE: Vaccine
    PRICE: $46.50
    PET SERVICE NO. 3
    SERVICE CODE: DG-4682
    SERVICE: Dog Spay
    DESC: Abdominal surgery to remove the ovaries and/or uterus
    (ovariohysterectomy).
    TYPE: Surgery
    PRICE: $57.50
    No where in my code do i even have any of this so how would the user be able to see this? Is this program designed to just display the SERVICE CODE: and then the user types in the DG-4682? etc etc..
    I ask this because I cannot view my dialog boxes because when I run the program i get nothing, just process completed, nothing else.

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

Maybe you are looking for

  • Cheque number assignment

    Hi, Can we assign the same cheque number to multiple payment documents? If so, what is the T-code and the steps. Thanks Sridevi

  • Can't download movies purchased from itunes on my ipad

    I have many movies purchased through iTunes store.  In the past I was able to download to my iPad to watch when out of wifi.  Now many titles, I cannot.  Previously, I downloaded Avengers and watched, now it won't. Why?

  • Sysprep and Capture TS problems

    I am trying to capture the image of a reference machine I have in VirtualBox. I am working in MDT 2012. The first pass on this I initiated the process from the CMD window starting the LiteTouch.wsf from in the scripts folder. This worked to a point,

  • Daylight savings time issue with iphone

    When syncing iphone to pc (Vista) and Microsoft Outlook 2007, the time on the iPhone is one hour LATER that it is on the computer source. It seems that, once again, Apple and Microsoft are at odds with each other and the new rules on Daylight Savings

  • Store takes forever to load and when it does images fail and text is not setup right?

    So I thought I had troubles loading the store with itunes, but now I notice it does load just takes forever and when it does the images are broken and the text is linear, not spread correctly like the page would have set it up.  I have tried all the