Cannot find symbol error when compiling in different packages

Hey all,
I'm trying to divide my project into a sensible hierarchy. This is what I want:
MyProject
MyProject/src ................................. where all the source files are (no further directories)
MyProject/classes
MyProject/classes/Main.class
MyProject/classes/classes2 ................ sorry for not being creative XD
MyProject/classes/classes2/Age.classNow, Age uses Main, and this is where the trouble is. I'm using javac directly to compile Age, and this is how I'm doing it:
//from MyProject
javac -cp classes src/Age.javaAnd I get this error:
bla bla bla...cannot find symbol
symbol  : variable Main
location: class classes2.Age
          years = (byte)(Main.year - m.getYear());
                         ^Main is already compiled and in place.
Also, this is how Age.java starts:
package classes2;
public class Age
{...etcI'm using JCreator as an IDE (and using it's own build function, the same error occurs, which is why I tried directly compiling the file).
Why can't javac find Main.class? I tried searching Google, but my particular problem didn't seem to crop up.
Hope I provided enough information, and ask if more is needed.
Many thanks :)

If Main is not in a package (which it appears not to be), then it cannot be referenced by any class that is in a package. If Main is in a package, then you'll need to refer to it by it's fully-qualified name (or import it as such) if it's not in the same package as the class that's referring to it, and Main.class will have to be in a directory that corresponds to its package.
Also, though the compiler may not require it, your source code directory structure should match your package hierarchy.

Similar Messages

  • Cannot find symbol error when compiling from cmd

    When compile and running program from Eclipse 3.3 everything works fine, but when trying to compile from cmd I get this error:
    C:\TEMP\1>javac A.java
    A.java:38: cannot find symbol
    symbol : class SwingWorker
    location: package javax.swing
    import javax.swing.SwingWorker;
    ^
    A.java:48: cannot find symbol
    symbol : class SwingWorker
    location: class A
    class Task extends SwingWorker {
    ^
    A.java:109: cannot find symbol
    symbol : method addPropertyChangeListener(A)
    location: class A.Task
    task.addPropertyChangeListener(this);
    ^
    A.java:110: cannot find symbol
    symbol : method execute()
    location: class A.Task
    task.execute();
    ^
    java -version get back: java version "1.6.0_14"....
    now, if i copy .class file that Eclipse made and just execute thet .class file from cmd everything works fine.
    here is the code, but i think that problems is somwhere else. i tried to serach on google, but... :(
    import java.awt.BorderLayout;
    import java.awt.Cursor;
    import java.awt.Insets;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.SwingWorker;
    public class A extends JPanel implements ActionListener, PropertyChangeListener {
        private JProgressBar progressBar;
        private JButton startButton;
        private JTextArea taskOutput;
        private Task task;
        class Task extends SwingWorker {
             * Main task. Executed in background thread.
    //        @Override
            public Void doInBackground() {
                 System.out.println("test");
                return null;
             * Executed in event dispatching thread
    //        @Override
            public void done() {
                Toolkit.getDefaultToolkit().beep();
                startButton.setEnabled(true);
                setCursor(null); //turn off the wait cursor
                taskOutput.append("Done!\n");
        public A() {
            super(new BorderLayout());
            //Create the demo's UI.
            startButton = new JButton("Start");
            startButton.setActionCommand("start");
            startButton.addActionListener(this);
            progressBar = new JProgressBar(0, 100);
            progressBar.setValue(0);
            progressBar.setStringPainted(true);
            taskOutput = new JTextArea(25, 50);
            taskOutput.setMargin(new Insets(5,5,5,5));
            taskOutput.setEditable(false);
            JPanel panel = new JPanel();
            panel.add(startButton);
            panel.add(progressBar);
            add(panel, BorderLayout.PAGE_START);
            add(new JScrollPane(taskOutput), BorderLayout.CENTER);
            setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
         * Invoked when the user presses the start button.
        public void actionPerformed(ActionEvent evt) {
            startButton.setEnabled(false);
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            //Instances of javax.swing.SwingWorker are not reusuable, so
            //we create new instances as needed.
            task = new Task();
            task.addPropertyChangeListener(this);
            task.execute();
         * Invoked when task's progress property changes.
        public void propertyChange(PropertyChangeEvent evt) {
            if ("progress" == evt.getPropertyName()) {
                int progress = (Integer) evt.getNewValue();
                progressBar.setValue(progress);
    //            taskOutput.append(String.format("Completed %d%% of task.\n", task.getProgress()));
         * Create the GUI and show it. As with all GUI code, this must run
         * on the event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("Veritas Backup");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new A();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }thank you very much!!!!

    Perhaps you are running an older version of javac. What do you get with "javac -version" or try compiling with the full path to jdk 1.6.0_14/bin/javac.

  • "cannot find symbol" error while compiling the RMI

    I am trying to implement a simple RMI.
    I have the following :
    1. HelloInterface which has the SayHello method defined.
    2. HelloImpl which has the implementation of Say Hello
    3. Server code
    4. Client code
    the HelloInterface compiles properly.
    but when i say javac HelloImpl
    package rmisample;
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    import java.rmi.RemoteException;
    public class HelloImpl extends UnicastRemoteObject implements HelloInterface{ --> this is where i get the error
    /** Creates a new instance of HelloImpl */
    public HelloImpl()throws RemoteException {
    super();
    public String SayHello(String s) throws RemoteException
    return "hello" +s;
    I get the following error:
    C:\Myjava\RMISample\src\rmisample>javac HelloImpl.java
    HelloImpl.java:18: cannot find symbol
    symbol: class HelloInterface
    public class HelloImpl extends UnicastRemoteObject implements HelloInterface{
    All 4 files are in the same directory.
    Am not sure what is going wrong and am new to this.
    Edited by: topcatin on Sep 14, 2007 6:52 AM

    The problem is probably that the compiler can't find the file with that class definition.
    Try changing your javac call so that is starts off
    javac -classpath .
    The dot is important!
    If it works, then go read up on classpaths.

  • "cannot find symbol" error in compiling

    I'm just begining to learn Java and I have the "Teach yourself Java in 21 Days" book. I can't get the code to work and every time I compile the VolcanoRobot.java, I get this error:
    "VolcanoRobot.java:25: cannot find symbol
    symbol : method showAttributes()
    location: class VolcanoRobot
    dante.showAttributes();
    ^
    VolcanoRobot.java:28: cannot find symbol
    symbol : method showAttributes()
    location: class VolcanoRobot
    dante.showAttributes();
    ^
    VolcanoRobot.java:31: cannot find symbol
    symbol : method showAttributes()
    location: class VolcanoRobot
    dante.showAttributes();
    ^
    VolcanoRobot.java:34: cannot find symbol
    symbol : method showAttributes()
    location: class VolcanoRobot
    dante.showAttributes();
    ^
    4 errors"
    and here is my code:
    "class VolcanoRobot {
    String status;
    int speed;
    float temperature;
    void checkTemperature() {
    if (temperature > 700) {
    status = "returning home";
    speed = 8;
    void showAtrributes() {
    System.out.println("Status: " +status);+
    +System.out.println("Speed: "+ speed);
    System.out.println("Temperature: " + temperature);
    public static void main(String[] arguments) {
    VolcanoRobot dante = new VolcanoRobot();
    dante.status = "exploring";
    dante.speed = 2;
    dante.temperature = 510;
    dante.showAttributes();
    System.out.println("Increasing speed to 3.");
    dante.speed = 3;
    dante.showAttributes();
    System.out.println("Changing temperature to 670.");
    dante.temperature = 670;
    dante.showAttributes();
    System.out.println("Checking the temperature.");
    dante.checkTemperature();
    dante.showAttributes();
    }"

    Use code tags when you post code.
    Post the code that produces the error - the code that you posted does not.
    The code you posted has the following errors
    VolcanoRobot.java:18: ')' expected
                    System.out.println("Status: " status);
                                                 ^
    VolcanoRobot.java:18: illegal start of expression
                    System.out.println("Status: " status);
                                                        ^
    VolcanoRobot.java:19: ')' expected
                    System.out.println("Speed: " speed);
                                                ^
    VolcanoRobot.java:19: illegal start of expression
                    System.out.println("Speed: " speed);Once those errors are fixed you get the errors that you posted.
    VolcanoRobot.java:25: cannot find symbolThe number in that line (25) tells you the exact line where the error appeared. Although sometimes the cause might be a line before that.
    It also tells you specifically what it doesn't like. In this case 'showAttributes'.
    Hint: So look at that line carefully. And look at the method carefully that that is supposed to call. They are not the same.

  • Cannot resolve symbol error when compiling a class that calls another class

    I've read all the other messages that include "cannot resolve symbol", but no luck. I've got a small app - 3 classes all in the same package. BlackjackDAO and Player compile OK, but BlackjackServlet throws the "cannot resolve symbol" (please see pertinent code below)...
    I've tried lots: ant and javac compiling, upgrading my version of tomcat, upgrading my version of jdk/jre, making sure my servlet.jar is being seen by the compiler (at least as far as I can see from the -verbose feedback)...any help would be GREAT! Thanks in advance...
    classes: BlackjackServlet, BlackjackDAO, Player
    package: myblackjackpackage
    tomcat version: 4.1.1.8
    jdk version: j2sdk 1.4.0
    ant version: 1.4.1
    I get the same error message from Ant and Javac...
    C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage>javac *.java -verbose
    C:\Tomcat4118\src\webapps\helloblackjack>ant all -verbose
    compile error:
    BlackjackServlet.java:55: cannot resolve symbol
    symbol: method addPlayer (javax.servlet.http.HttpServletRequest,javax.servlet.http.Http
    ServletResponse)
    location: class myblackjackpackage.BlackjackServlet
              addPlayer(request, response);
    ^
    My code is:
    package myblackjackpackage;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.lang.*;
    /** controller servlet in a web based blackjack game application @author Ethan Harlow */
    public class BlackjackServlet extends HttpServlet {
         private BlackjackDAO theBlackjackDAO;
         public void init() throws ServletException {
    String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String dbUrl = "jdbc:microsoft:sqlserver://localhost:1433";
    String userid = "testlogin";
    String passwrd = "testpass";
         try {
         theBlackjackDAO = new BlackjackDAO(driver, dbUrl, userid, passwrd);
         catch (IOException exc) {
              System.err.println(exc.toString());
         catch (ClassNotFoundException cnf) {
              System.err.println(cnf.toString());
         catch (SQLException seq) {
              System.err.println(seq.toString());
    public void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
    doGet(request, response);
    public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
         String command = request.getParameter("command");
         if (command == null || (command.equals("stats"))) {
         else if (command.equals("add")) {
              try {
    //the following line is caught by compiler
              addPlayer(request, response);
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<html>");
              out.println("<body>");
              out.println("<p>Hi, your command was " + request.getParameter("command") + "!!!</p>");
              out.println("</body>");
              out.println("</html>");
              catch (Exception exc) {
                   System.err.println(exc.toString());
         else if (command.equals("play")) {
         else if (command.equals("bet")) {
         else if (command.equals("hit")) {
         else if (command.equals("stand")) {
         else if (command.equals("split")) {
         else if (command.equals("double")) {
         else if (command.equals("dealerdecision")) {
         else if (command.equals("reinvest")) {
         else if (command.equals("changebet")) {
         else if (command.equals("deal")) {
    package myblackjackpackage;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.lang.*;
    public class BlackjackDAO {
         private Connection myConn;
         public BlackjackDAO(String driver, String dbUrl, String userid, String passwrd)
                   throws IOException, ClassNotFoundException, SQLException {
              System.out.println("Loading driver: " + driver);
              Class.forName(driver);
              System.out.println("Connection to: " + dbUrl);
              myConn = DriverManager.getConnection(dbUrl, userid, passwrd);
              System.out.println("Connection successful!");
         public void addPlayer(HttpServletRequest request, HttpServletResponse response)
                   throws IOException, SQLException {
    //I've commented out all my code while debugging, so I didn't include
    //any here     
    compiler feedback
    C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage>javac *.java -verbose
    [parsing started BlackjackDAO.java]
    [parsing completed 90ms]
    [parsing started BlackjackServlet.java]
    [parsing completed 10ms]
    [parsing started Player.java]
    [parsing completed 10ms]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Object.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/sql/Connection.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/String.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/io/IOException.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/ClassNotFoundException.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/sql/SQLException.class)]
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/http/HttpServletRequ
    est.class)]
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/http/HttpServletResp
    onse.class)]
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/http/HttpServlet.cla
    ss)]
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/GenericServlet.class
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/Servlet.class)]
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/ServletConfig.class)
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/io/Serializable.class)]
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/ServletException.cla
    ss)]
    [checking myblackjackpackage.BlackjackDAO]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Throwable.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Exception.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/System.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/io/PrintStream.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/io/FilterOutputStream.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/io/OutputStream.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Class.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/sql/DriverManager.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/util/Properties.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Error.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/RuntimeException.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/StringBuffer.class)]
    [wrote BlackjackDAO.class]
    [checking myblackjackpackage.BlackjackServlet]
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/ServletRequest.class
    BlackjackServlet.java:55: cannot resolve symbol
    symbol : method addPlayer (javax.servlet.http.HttpServletRequest,javax.servlet
    .http.HttpServletResponse)
    location: class myblackjackpackage.BlackjackServlet
    addPlayer(request, response);
    ^
    [loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/ServletResponse.clas
    s)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/io/PrintWriter.class)]
    [loading c:\j2sdk14003\jre\lib\rt.jar(java/io/Writer.class)]
    [checking myblackjackpackage.Player]
    [total 580ms]
    1 error
    C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage>
    and here's the ant feedback...
    C:\Tomcat4118\src\webapps\helloblackjack>ant all -verbose
    Ant version 1.4.1 compiled on October 11 2001
    Buildfile: build.xml
    Detected Java version: 1.4 in: c:\j2sdk14003\jre
    Detected OS: Windows 2000
    parsing buildfile C:\Tomcat4118\src\webapps\helloblackjack\build.xml with URI =
    file:C:/Tomcat4118/src/webapps/helloblackjack/build.xml
    Project base dir set to: C:\Tomcat4118\src\webapps\helloblackjack
    Build sequence for target `all' is [clean, prepare, compile, all]
    Complete build sequence is [clean, prepare, compile, all, javadoc, deploy, dist]
    clean:
    [delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build
    [delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\images\a_s.g
    if
    [delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\images\q_s.g
    if
    [delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build\im
    ages
    [delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\index.html
    [delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\newplayer.ht
    ml
    [delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-INF\clas
    ses\myblackjackpackage\BlackjackDAO.class
    [delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build\WE
    B-INF\classes\myblackjackpackage
    [delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build\WE
    B-INF\classes
    [delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-INF\web.
    xml
    [delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build\WE
    B-INF
    [delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build
    prepare:
    [mkdir] Created dir: C:\Tomcat4118\src\webapps\helloblackjack\build
    [copy] images\a_s.gif added as C:\Tomcat4118\src\webapps\helloblackjack\bui
    ld\images\a_s.gif doesn't exist.
    [copy] images\q_s.gif added as C:\Tomcat4118\src\webapps\helloblackjack\bui
    ld\images\q_s.gif doesn't exist.
    [copy] index.html added as C:\Tomcat4118\src\webapps\helloblackjack\build\i
    ndex.html doesn't exist.
    [copy] newplayer.html added as C:\Tomcat4118\src\webapps\helloblackjack\bui
    ld\newplayer.html doesn't exist.
    [copy] WEB-INF\web.xml added as C:\Tomcat4118\src\webapps\helloblackjack\bu
    ild\WEB-INF\web.xml doesn't exist.
    [copy] omitted as C:\Tomcat4118\src\webapps\helloblackjack\build is up to
    date.
    [copy] images added as C:\Tomcat4118\src\webapps\helloblackjack\build\image
    s doesn't exist.
    [copy] WEB-INF added as C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-
    INF doesn't exist.
    [copy] Copying 5 files to C:\Tomcat4118\src\webapps\helloblackjack\build
    [copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\images\q_s.gif
    to C:\Tomcat4118\src\webapps\helloblackjack\build\images\q_s.gif
    [copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\images\a_s.gif
    to C:\Tomcat4118\src\webapps\helloblackjack\build\images\a_s.gif
    [copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\index.html to C
    :\Tomcat4118\src\webapps\helloblackjack\build\index.html
    [copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\newplayer.html
    to C:\Tomcat4118\src\webapps\helloblackjack\build\newplayer.html
    [copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\WEB-INF\web.xml
    to C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-INF\web.xml
    compile:
    [mkdir] Created dir: C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-INF\
    classes
    [javac] myblackjackpackage\BlackjackDAO.class skipped - don't know how to ha
    ndle it
    [javac] myblackjackpackage\BlackjackDAO.java added as C:\Tomcat4118\src\weba
    pps\helloblackjack\build\WEB-INF\classes\myblackjackpackage\BlackjackDAO.class d
    oesn't exist.
    [javac] myblackjackpackage\BlackjackServlet.java added as C:\Tomcat4118\src\
    webapps\helloblackjack\build\WEB-INF\classes\myblackjackpackage\BlackjackServlet
    .class doesn't exist.
    [javac] myblackjackpackage\Player.java added as C:\Tomcat4118\src\webapps\he
    lloblackjack\build\WEB-INF\classes\myblackjackpackage\Player.class doesn't exist
    [javac] Compiling 3 source files to C:\Tomcat4118\src\webapps\helloblackjack
    \build\WEB-INF\classes
    [javac] Using modern compiler
    [javac] Compilation args: -d C:\Tomcat4118\src\webapps\helloblackjack\build\
    WEB-INF\classes -classpath
    "C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-I
    NF\classes;
    C:\tomcat4118\common\classes;
    C:\tomcat4118\common\lib\activation.jar;
    C:\tomcat4118\common\lib\ant.jar;
    C:\tomcat4118\common\lib\commons-collections.jar;
    C:\tomcat4118\common\lib\commons-dbcp.jar;
    C:\tomcat4118\common\lib\commons-logging-api.jar;
    C:\tomcat4118\common\lib\commons-pool.jar;
    C:\tomcat4118\common\lib\jasper-compiler.jar;
    C:\tomcat4118\common\lib\jasper-runtime.jar;
    C:\tomcat4118\common\lib\jdbc2_0-stdext.jar;
    C:\tomcat4118\common\lib\jndi.jar;
    C:\tomcat4118\common\lib\jta.jar;
    C:\tomcat4118\common\lib\mail.jar;
    C:\tomcat4118\common\lib\mysql_uncomp.jar;
    C:\tomcat4118\common\lib\naming-common.jar;
    C:\tomcat4118\common\lib\naming-factory.jar;
    C:\tomcat4118\common\lib\naming-resources.jar;
    C:\tomcat4118\common\lib\servlet.jar;
    C:\tomcat4118\common\lib\tools.jar;
    C:\j2sdk14003\lib\tools.jar;
    C:\tomcat4118\ant141\lib\servlet.jar;
    C:\tomcat4118\ant141\lib\jaxp.jar;
    C:\tomcat4118\ant141\lib\crimson.jar;
    C:\tomcat4118\ant141\lib\ant.jar;
    C:\Tomcat4118\src\webapps\helloblackjack;
    C:\mysql\jdbc_dvr\mm.mysql.jdbc-1.2c;
    C:\Program Files\SQLserverjdbcdriver\lib\msbase.jar;
    C:\Program Files\SQLserverjdbcdriver\lib\msutil.jar;
    C:\Program Files\SQLserverjdbcdriver\lib\mssqlserver.jar"
    -sourcepath C:\Tomcat4118\src\webapps\helloblackjack\src -g -O
    [javac] Files to be compiled:
    C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage\BlackjackDAO
    .java
    C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage\BlackjackSer
    vlet.java
    C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage\Player.java
    [javac] C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage\Blac
    kjackServlet.java:55: cannot resolve symbol
    [javac] symbol : method addPlayer (javax.servlet.http.HttpServletRequest,j
    avax.servlet.http.HttpServletResponse)
    [javac] location: class myblackjackpackage.BlackjackServlet
    [javac] addPlayer(request, response);
    [javac] ^
    [javac] 1 error
    BUILD FAILED
    C:\Tomcat4118\src\webapps\helloblackjack\build.xml:212: Compile failed, messages
    should have been provided.
    at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:559)
    at org.apache.tools.ant.Task.perform(Task.java:217)
    at org.apache.tools.ant.Target.execute(Target.java:184)
    at org.apache.tools.ant.Target.performTasks(Target.java:202)
    at org.apache.tools.ant.Project.executeTarget(Project.java:601)
    at org.apache.tools.ant.Project.executeTargets(Project.java:560)
    at org.apache.tools.ant.Main.runBuild(Main.java:454)
    at org.apache.tools.ant.Main.start(Main.java:153)
    at org.apache.tools.ant.Main.main(Main.java:176)
    Total time: 1 second
    C:\Tomcat4118\src\webapps\helloblackjack>

    yes!
    early on i tried: BlackjackDAO.addPlayer(request, response);
    instead of: theBlackjackDAO.addPlayer(request, response);
    you rock - thanks a ton

  • 'Cannot find symbol' error after putting class into package

    I'm sure this is probably just a stupid mistake that I am making somewhere, but I can't figure it out.
    I have written a Java program, "LineConsole.java" and an interface, "LineConsoleKeyListener.java". LineConsole.java uses the interface (it does not implement it... it uses LineConsoleKeyListener objects in the program). If I put the two .java files into the same directory and compile them, everything works.
    So now I want to put them in a package called "LineConsole". I thought all I had to do was move the two files into a folder called "LineConsole" and add "package LineConsole;" to the top of each file. I did that, but now LineConsole.java does not compile. It complains that it cannot find the LineConsoleKeyListener interface, even though it's right there in the same directory.
    What am I doing wrong? Do members of a package have to import themselves or something?
    Thanks!
    Message was edited by:
    L4E_WakaMol-King

    Thanks guys :)
    It's working now.
    One more question...
    Right now I have 3 files in a folder names "LineCon":
    - LineConsole.class
    - LineConsoleKeyListener.class
    - wincbreak.dll
    If I copy that directory into the same directory as some other program I am writing, I can use those classes just like they are in a package. But is there any way to zip that package into a jar file? I know how to create jar files, but is there a way to make them behave like packages?
    I have tried creating a jar file with the individual files and also with all three files in a directory. The jar file is created successfully, but I cannot copy that jar file into the directory of a program and use the classes within it as if they were a package.
    I guess my ultimate question here is... how do I import a .class file that is in a jar file?

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

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

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

Maybe you are looking for

  • Cannot send email from Exchange 2007 to Exchange 2013

    Hello Anyone, Anyone can help? I've prepare MS Exchange 2013 already, for Migration MS Exchange 2007 and I got the issue. My issue is I can't send email from Exchange 2007 to Exchagen 2013, but for Exchange 2013 can send email to Exchange 2007, is my

  • Abstract method called in an abstract class

    Hello, I am writing some code that I'd like to be as generic as possible. I created an abstract class called Chromozome. This abstract class has a protected abstract method called initialize(). I also created an abstract class called Algorithm which

  • Assigning position hierarchy within Org Model

    Hi, have maintained the org model with sales org and position in crm 5.0. This position is President sales and would like to maintain General Manager under this position as a subordinate. While doing so, I get the following message: <b>Before you sel

  • WLC and WLSE

    Hi Netpro what is the difference between the WLC and WLSE? thanks

  • JMS Compliance Test

    Hello, How can I test JMS compliance for JMS providers? Can anybody give me a good idea to do JMS compatibility test for JMS providers? Do you know any JMS compliance test suite? Thank you for your any assistance! Sunill.