• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javac generating Wierd error during compilation

 
Suvojit Chakraborty
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
  • 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
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
read this. may be this can help you.
 
Nidhi Sar
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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/
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • 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!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic