Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default cannot find symbol

    Hi,

    So...I'm just learning java for fun, using various tutorials around the web. Here's the one I'm on right now...

    Building an Application: Introduction

    I got past a lot of compiling errors last night/this morning, but now I've run into something I don't really understand.

    The error is;
    DiveLog.java:88:cannot find symbol
    symbol : class Resources
    location: class divelog.DiveLog
    new Welcome(), (Except the ^ is below the capital W on Welcome)
    ^

    I actually get 6 errors total, but they all look like this(One for Dives, Welcome, Resources, Statistics, Diver, and WebSite). I have tried searching, but to no avail. Hopefully there's something I'm missing!

    Here is my code, and no, it is not yet complete :)

    Java Code:
    package divelog;
    
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    
    
    public class DiveLog
    {
        //Opens DiveLog class
    
        private JTabbedPane tabbedPane;
        private JFrame dlframe;
    
    
    
        public DiveLog()
        {
            //Opens DiveLog constructor
    
            //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);
    
            // Calls 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 class constructor
    
        private void populateTabbedPane()
        {
            // Opens populateTabbedPane method definition
            // 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 definition
            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);
        }// Closes buildMenu method
    
    
        // main method and entry point for app
        public static void main(String[] args)
        {
            // Opens main method
    
            DiveLog dl = new DiveLog();
    
    
        } // Closes main method
    
    
    
    } //Ends class DiveLog
    Any help is greatly appreciated...

    Cheers,
    Limbless
    Last edited by LimblessQuasar; 06-11-2011 at 09:59 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You're calling new Resources() here:

    Java Code:
            tabbedPane.addTab("Resources",
                              null,
                              new Resources(),
    but where is your Resources class code?

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,772
    Blog Entries
    7
    Rep Power
    21

    Default

    You may know that Welcome, Diver etc. are classes but the compiler doesn't know that, nor does it know where to find the compiled code for those classes, nor even their source code; you have to tell it where it can find them. You either specify a classpath for that purpose or a source path. Type 'javac -help' for the details.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default

    Thanks both for the quick replies!

    Quote Originally Posted by Fubarable View Post
    You're calling new Resources() here:

    Java Code:
            tabbedPane.addTab("Resources",
                              null,
                              new Resources(),
    but where is your Resources class code?
    It's in a seperate java file. Isn't that where it should be? It's basically nothing at this point, as I'm supposed to compile this first - just to get a look at it - and then get to all the various classes.

    Quote Originally Posted by JosAH View Post
    You may know that Welcome, Diver etc. are classes but the compiler doesn't know that, nor does it know where to find the compiled code for those classes, nor even their source code; you have to tell it where it can find them. You either specify a classpath for that purpose or a source path. Type 'javac -help' for the details.

    kind regards,

    Jos
    Okay, I'm going to refrain from being totally helpless here. (Or at least try to). -help is pretty straightforward; use -classpath for user class files/annotation, use -sourcepath for input source files. But I'm unsure which to use, or how to use them. Should I be specifying the classpath/sourcepath in the code itself? (This sounds like it would more sense, but I'm doubtful) Or should I just be adding these as part of my javac command? Like; javac -classpath C:\Program Files\DiveLog DiveLog.java (I tried that and it didn't work, so I'm guessing I just typed it wrong).

    Cheers,
    Limbless

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    Like; javac -classpath C:\Program Files\DiveLog DiveLog.java (I tried that and it didn't work, so I'm guessing I just typed it wrong).
    When a path contains spaces, it needs to be enclosed in quote. Note that this isn't Java-specific.

    db

Similar Threads

  1. Cannot Find Symbol
    By Concacaf in forum New To Java
    Replies: 5
    Last Post: 05-09-2011, 01:47 PM
  2. Still cannot find symbol!
    By Johanis in forum New To Java
    Replies: 1
    Last Post: 11-04-2010, 05:32 PM
  3. Cannot find symbol
    By SarahB in forum New To Java
    Replies: 0
    Last Post: 03-06-2010, 04:03 PM
  4. Replies: 9
    Last Post: 10-18-2008, 09:26 PM
  5. Replies: 3
    Last Post: 05-01-2008, 09:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •