• Post Reply Bookmark Topic Watch Topic
  • New Topic

Package problem...  RSS feed

 
Sean O'Donnell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings. I am having a compilation problem resulting from unrecognized packages. I am trying to run a small example found in a SCJP mock exam. The following classes are in 2 separate files...

package p1;

public class Super {
protected void say ( String s ) {
System.out.println ( s ) ;
}
}



package p1;

public class SubOne extends Super { }




I get the following when compiling SubOne.java :

SubOne.java:3: cannot resolve symbol
symbol : class Super
location: class p1.SubOne
public class SubOne extends Super { }
^
1 error


(the carrot should be under the "S" in Super, not the "p" in public)

I believe the problem is outside of the code, but I'm not sure what...

Thanks.
Sean
[ February 03, 2006: Message edited by: Sean O'Donnell ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you're doing this from the command line ...

What is your current directory relative to one called p1?

What does your JavaC command look like?

HERE is something I put together for this kind of question. Let me know if it helps at about #3.
 
Arvind Sampath
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean,

Welcome to JavaRanch !

I guess you are trying to compile SubOne class from inside the 'p1' folder. In this case your classpath will be set to 'p1' folder and the JVM is looking for p1.Super starting from the folder 'p1'.

Try compiling the SuperOne class by going one level back from the 'p1' folder like "javac p1\SubOne.java". This will solver your problem.

I am not sure with my explanation. Pls correct me in case am wrong


Cheers,
Arvind
 
Sean O'Donnell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you for your quick responses.

I did not have my classpath set properly and was trying to compile within the package directory without the -classpath option.

I updated my classpath and am now able to compile with proper results.

Thanks again for your help!

sean
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!