Solved

Java Package Classes Cannot Find Symbol

Posted on 2010-11-29
5
747 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 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now