File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes interfaces used to work on my system but now they dont :) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "interfaces used to work on my system but now they dont :)" Watch "interfaces used to work on my system but now they dont :)" New topic
Author

interfaces used to work on my system but now they dont :)

sunil mirani
Ranch Hand

Joined: Jan 24, 2001
Posts: 36
this is the code
/*Inter.java*/
interface Inter{
void disp();
}
/*B.java*/
class A implements Inter{
public void disp(){
System.out.println("This is working ???");
}
}
public class B {
public static void main(String args[]){
Inter obj = new A();
obj.disp();
}
}
on compiling it gives this error :
C:\examples\inter\B.java:1: cannot resolve symbol
symbol : class Inter
location: class A
class A implements Inter{
^
C:\examples\inter\B.java:9: cannot resolve symbol
symbol : class Inter
location: class B
Inter obj = new A();
^
2 errors

But if i put the interface i the file B.java it works..
plz tell me ??? what to do ??
Susan Hoover
Ranch Hand

Joined: Jan 04, 2001
Posts: 64
The thing that comes to mind is the package structure. Make sure that Inter and B are in the same package. If you don't specify a "package foo.bar;" line at the top of your files, then Inter and B are in the same package and must be in the same directory, which is the directory you're compiling from.
Since you have provided the output, I'm going to assume that C:\examples\inter is the directory that contains both Inter.java and B.java. There are several ways you can structure this:
1. No package statements.
This means that C:\examples\inter is the root of your package structure, and you have to either compile from C:\examples\inter or use the -sourcepath C:\examples\inter option.
2. package inter;
This means that C:\examples is the root of your package structure, and you have to either compile from C:\examples or use the -sourcepath C:\examples option.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
sunil:
the code you posted, in the same format, works fine on my
system.
pl. check your env.
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
sunil mirani
Ranch Hand

Joined: Jan 24, 2001
Posts: 36
Hi Susan,
Susan, I dont want to use a package for this , i think there is a problem in the env setting of my system it is a 98 if you tell me the class path i shall try.
the same code works on other machines, i too have checked it.

Originally posted by Susan Hoover:
The thing that comes to mind is the package structure. Make sure that Inter and B are in the same package. If you don't specify a "package foo.bar;" line at the top of your files, then Inter and B are in the same package and must be in the same directory, which is the directory you're compiling from.
Since you have provided the output, I'm going to assume that C:\examples\inter is the directory that contains both Inter.java and B.java. There are several ways you can structure this:
1. No package statements.
This means that C:\examples\inter is the root of your package structure, and you have to either compile from C:\examples\inter or use the -sourcepath C:\examples\inter option.
2. package inter;
This means that C:\examples is the root of your package structure, and you have to either compile from C:\examples or use the -sourcepath C:\examples option.

Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

I am just wondering if you have specified "." in your
classpath variable ie; the current working dir.
regds.
- satya
 
jQuery in Action, 2nd edition
 
subject: interfaces used to work on my system but now they dont :)
 
Similar Threads
using package getting compiler error
import mypack.*; (asterisk and without asterisk)
Comilation Problem
Question on casting
Help with Package understanding