Solved

Java Package Classes Cannot Find Symbol

Posted on 2010-11-29
5
753 Views
Last Modified: 2012-05-10
Hi,
I am creating a Java program in a package called jblog. This consists of the main class BlogServer which needs to create objects of other classes in the same package.

I have stored all the Java source files for my package in a <path to source directory>/jblog
and am compiling these to the directory <path to classes directory>/jblog

When I attempt to compile the main java class - BlogServer I get Symbol Not Found errors for some of the other classes in my directory, the BlogServerInterface class (as well as other classes):

# javac -d ../../classes/jblog/ BlogServer.java
BlogServer.java:9: cannot find symbol
symbol: class BlogServerInterface
public class BlogServer implements BlogServerInterface

Both my BlogServer class and BlogServerInterface class are in the same jblog/ directory and have the package jblog line on the first line of the source file. Why can't the compiler find the BlogServerInterface class?

Thanks.

0
Comment
Question by:SnowCrash89
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 34235697
you need to specify the classpath

javac -d ../../classes/jblog/ -classpath ../../classes BlogServer.java
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 34235699
that may actually be:


javac -d ../../classes/jblog/ -classpath ../../classes/blog BlogServer.java

its unclear if you are using packages or not
0
 

Author Comment

by:SnowCrash89
ID: 34235766
Ah, that worked, so when you're specifying a package name in your java files you have to use the -classpath parameter when compiling?
0
 
LVL 92

Expert Comment

by:objects
ID: 34235820
no, you need to specify the classpath if it needs to find dependant classes
the classpath is used to lookup classes
0
 

Author Comment

by:SnowCrash89
ID: 34235844
That's strange though, I've managed to compile succesfully a class with dependant classes without having to specify the classpath. Anyway problem solved.
Thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question