• 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

classpath problem

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I've been trying to execute a program for now 2 days and I'm not able to get my classpath correct. Here I'm writing the code as well as the commands that I'm giving. Kindly help.

Animal.java in C:\jdk\bin\corejava folder


and compiled using javac -d . Animal.java command from c:\jdk\bin\corejava prompt.

Bird.java in the same folder


Now I don't know what should I give in as a value of classpath so that my Bird.java file compiles. Everytime it will give me bad class file : Animal

Thanks
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this is your class definition

,

then it must be placed in a directory named A.
 
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After compiling Animal you should end up with a directory "A" under the current directory and "Animal.class" in that. The classpath when compiling "Bird" should just include the current directory (not "A" or "A.Animal"). After compiling "Bird" there should be a "Bird.class" in the current directory.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct to use javac -d . Animal.java, which seems to work when I use Windows.
Try deleting the Animal.java file after you have compiled it into "A". I did. It worked (on Linux). No idea why you are getting this error.

Try Keith Lynn's suggestion and put Animal in directory A and back. Note you have to compile Animal from a command prompt in A before you can try compiling Bird from a command line in C:\jdk\bin\corejava.

BTW: You oughtn't to be keeping your exercises in a jdk\bin folder. Make yourself a "JavaPrograms" folder in MyDocuments or C drive or somewhere, so as to avoid confusion with the jdk files.
 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks....Thanks...Thanks all of you. Finally my program is running.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We're only too pleased to help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic