Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java Package Classes Cannot Find Symbol

Posted on 2010-11-29
5
Medium Priority
?
759 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
  • 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

916 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