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

Package creation

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i created a directory called pack1.
in this i defiene a super class like this

After compiling this,i define a child class like this

when compiling child1.java .it is giving error like this"super class pack.parent1 of pack.child1
not found"
anybody help me to run this class.
thanks in advance,
Neelima
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ July 15, 2003: Message edited by: Dirk Schreckmann ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The compiler needs to be able to locate the base of your package structure through the CLASSPATH setting. So, the folder that holds the pack folder, needs to be somehow included in the CLASSPATH.
Try the following. (I'm working from my K:\java\temp folder.)
1. Create the pack folder - K:\java\temp\pack
2. Inside the K:\java\temp\pack folder, create parent1.java
3. From the command line, cd to K:\java\temp\pack and compile.
K:\java\temp\pack> javac parent1.java
It should compile successfully.
4. Inside the K:\java\temp\pack folder, create child1.java
5. From the command line, cd to K:\java\temp (NOT K:\java\temp\pack) and compile.
K:\java\temp> javac pack\child1.java
It should compile successfully, if your CLASSPATH is configured to include the current working directory (specified with a simple . - period). If it doesn't compile, then fix your CLASSPATH accordingly. Feel free to ask about how to do so.
6. You can now run the child1 program from the command line.
K:\java\temp>java pack.child1
And it should output the following.
Hello
Hello
Neelima Paramsetty
7. Any luck?
[ April 12, 2004: Message edited by: Dirk Schreckmann ]
 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using an IDE Tool will ease your classpath stress as you can setup/edit/customise them for individual projects.
Try using Forte by Sun Microsystems for example..its free.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me suggest that once you figure out the whole CLASSPATH thing, it's easy. I'd suggest not using an IDE at first. Using one will hide some of those details that a programmer might do well to be familiar with.
 
Neelima Paramsetty
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dirk Schreckmann ,
Thanks for ur help.How to fix my class path?It is giving error when compiling child,java.
thanks,
Neelima
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic