Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Compiling Package, cannot find symbol

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    66
    My Mood
    Relaxed
    Thanks
    12
    Thanked 4 Times in 4 Posts

    Default Compiling Package, cannot find symbol

    Hello everyone,

    I've been trying to get my package to work but I keep running into a cannot find symbol error. Since this is a homework assignment, I'll just use broad examples to describe my problem. Let's assume that I have these files...

    In the upper level folder:
    Food.java
    public class Food{
     
        private Fruits<String> fruits;
        private Vegetables<String> vegetables;
     
        public Food(){
            fruits = new Fruits<String>();
            vegetables = new Vegetables<String>();
        }
        ...
    }

    In the lower level folder, let's assume it's called type:
    Fruits.java
    Vegetables.java

    In the Fruits.java and Vegetables.java, I have the line package type; declared.

    When compiling, I'm using the command:
    javac type/Fruits.java
    javac type/Vegetables.java
    *note* The two files compile fine without error

    When I try: javac Food.java
    Food.java:7: cannot find symbol
    symbol  : class Fruits
    location: class Food<E>
            private Fruits<String> fruits;
                    ^
    Food.java:8: cannot find symbol
    symbol  : class Vegetables
    location: class Food<E>
            private Vegetables<String> vegetables;
                    ^
    Food.java:11: cannot find symbol
    symbol  : class Fruits
    location: class Food<E>
                    fruits = new Fruits<String>();
                                ^
    Food.java:12: cannot find symbol
    symbol  : class Vegetables
    location: class Food<E>
                    vegetables = new Vegetables<String>();
                                ^
    4 errors

    Any input is appreciated and thanks for your time, Actinistia.

    *edit* I figured out that I had bad class files in my directory. I recompiled it and it worked out fine. Sorry for the inconvenience.
    Last edited by Actinistia; November 6th, 2012 at 05:22 PM. Reason: Solved


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,360
    My Mood
    Hungover
    Thanks
    144
    Thanked 626 Times in 537 Posts

    Default Re: Compiling Package, cannot find symbol

    You need to provide an SSCCE that demonstrates exactly what you're doing- the code you posted does not generate the error you're talking about, and we need to know exactly how you're declaring your packages and classes.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. [SOLVED] Cannot Find Symbol
    By ChicoTheMan94 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 25th, 2012, 02:46 PM
  2. cannot find symbol
    By lanpan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 1st, 2012, 07:13 AM
  3. Cannot find symbol
    By BadgerWatch in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 6th, 2011, 10:25 PM
  4. Cannot find Symbol?
    By defmetalhead in forum What's Wrong With My Code?
    Replies: 8
    Last Post: July 5th, 2011, 08:48 AM
  5. Cannot find symbol?
    By stealthmonkey in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 10th, 2010, 09:02 PM