• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Package problem...

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic