• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ??
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sunil:
the code you posted, in the same format, works fine on my
system.
pl. check your env.
regds.
- satya
 
sunil mirani
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am just wondering if you have specified "." in your
classpath variable ie; the current working dir.
regds.
- satya
 
reply
    Bookmark Topic Watch Topic
  • New Topic