Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

javac generating Wierd error during compilation

 
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends

I am reading Kathy Sierra and I wish to give SCJP exam.
Today when I tried to test the concept of protected V/S Default access modifier I got struck with a problem.

Below is the code:


If I try to compile it I get following error:


C:\Program Files\Java\jdk1.5.0_06\bin>javac ProtTestChild.java error: cannot read: ProtTestChild.java 1 error C:\Program Files\Java\jdk1.5.0_06\bin>



Can anyone tell me what could be the problem??


Thanks
BR
Suvojit
 
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
read this. may be this can help you.
 
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suvojit,

Your code is fine. The compilation error seems to suggest that either the file protTestChild.java is deleted/renamed before running javac or else it is hidden/not readable.

Have you checked the location and "file attributes" of the file?

HTH,
Nidhi
 
Suvojit Chakraborty
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Neha Daga wrote:read this. may be this can help you.



Thanks a lot for your quick reply.
I got the solution from some other forum. I needed to execute the command as C:\Program Files\Java\jdk1.5.0_06\bin>javac xyz/ProtTestChild.java

But I thank you Neha, the link you gave proved to be something which I have been searching for a long time.I was in a habit of saving my programs in bin directory although I knew its not a good practice but since I was not clear with the classpaths and environment variable so I had to do it against my will.

It would be a great help if you can tell me more about classpaths and environment variable or may be give some other usefull links to study.

Thank you Nidhi for your help.

Thanks a lot
BR
Suvojit
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.ibm.com/developerworks/library/j-classpath-unix/

if you want the same article is for windows : http://www.ibm.com/developerworks/library/j-classpath-windows/
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Word of advice: Don't keep any of your source and class files inside of the JDK's bin directory (or anywhere else in the JDK directory, for that matter). It's bound to create problems.
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Word of advice: Don't keep any of your source and class files inside of the JDK's bin directory (or anywhere else in the JDK directory, for that matter). It's bound to create problems.



yup... correct!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
About the names of your classes: Using the names "Parent" and "Child" for superclasses and subclasses is really wrong; inheritance in OO programming is not the same as biological inheritance. Confusing the OO programming concept of inheritance with the biological meaning of the word will make it harder for you to understand what "inheritance" means with regard to programming.

See here for more about this.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic