• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Java classpath,class not found error  RSS feed

 
Ranch Hand
Posts: 640
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have directory c:\RMI\src\java\rmiExample

Under this directory there are two classes which belong to same package rmiExample.

There is a Hello.java class and HelloInterface.java class

Hello.java implements the HelloInterface.java interface.

But when I compile the Hello.java from command prompt from c:\RMI\src\java\rmiExample directory I get error that can not find symbol HelloInterface

Not sure why java is unable to locat ehte interface if both the class and the interface are in the same package and directory.


Any pointers?

Thanks

 
Marshal
Posts: 60065
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your classpath?
Do any of those classes have package declarations?
 
trupti nigam
Ranch Hand
Posts: 640
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the java code

 
trupti nigam
Ranch Hand
Posts: 640
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:What is your classpath?
Do any of those classes have package declarations?



My CLasspath is: C:\RMI\src\java\rmiExample
 
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Classpaths can be tricky, especially once you start using packages ... which you should always do of course. Here, if you compile both classes at once it should work:

* rmiExample > javac *.java

But if you want to compile the interface first, then you'll have to give a classpath when compiling Hello.java, and the classpath entry in this case is the the directory above rmiExample:

* rmiExample > javac -cp .. Hello.java

When the compiler sees a reference to rmiExample.HelloInterface, it looks for the class file in an rmiExample directory relative to each entry in the classpath.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!