• 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

Asking you the two problems:

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
package Base;
class Base{
protected void amethod(){
System.out.println("amethod");
}}
class Class1 extends Base{
public static void main(String argv[]){
Base b = new Base();
b.amethod();
}
}//Why it can compile but throw a "NoClassDefFoundErro"

second:
In the SCJP examination,whether it should need us to different from reserved words
and key words or not :
if it demanded,please tell me what are the keywords,and what are reserved
words in SCJP examination?
Thanks a lot~~
[ February 23, 2002: Message edited by: Tu Ran ]
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. What is the stack trace exactly? What is command line you use to run the program? Sounds like a classpath problem to me...
Try going into the directory Base and type:
java -classpath . Base.Class1
or if you are in directory Base you can type
java -classpath .. Base.Class1
let me know
2. Keywords have been heavily discussed in the following threads:
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=014367
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=014586
[ February 23, 2002: Message edited by: Valentin Crettaz ]
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ran your code, and no problem with it. The problem is probably with your class path. Did
you run your code inside package or outside it?
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Valentin & Holmes,
Do I have to create Base directory and move the .class files to Base dir by my own? Is there a way to get it done automatically? Since javac doesn't create Base dir for you even though we specify the package as Base in our java file.
Thanks,
Jenny
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you cannot automatically generate a package specified by you from my understanding.
What if you have many files in one package? You must move all these files inside this package if
packane name for these files are specified on the first line of your code. Unless you do not specify, then you will have a default package that is your current directory.

Originally posted by Jenny Yin:
Hi Valentin & Holmes,
Do I have to create Base directory and move the .class files to Base dir by my own? Is there a way to get it done automatically? Since javac doesn't create Base dir for you even though we specify the package as Base in our java file.
Thanks,
Jenny

 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic