• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package and import doubt

 
adam Lui
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got the class files in the same directory course:
a.java


Student

the compiler complaints on a.java about not being able to find Student.
i really dont have a clue why..
pls help!

(even i put course.Student instead of Student in declaration)
 
Kinnaree Patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried running the code you have wrote and this code is working fine on my machine. It displays the result 20 as expected.
[ November 14, 2007: Message edited by: Kinnaree Patel ]
 
adam Lui
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any system settings or classpath invocation on the command has to be specified to run this code?
 
Kinnaree Patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by adam Lui:
is there any system settings or classpath invocation on the command has to be specified to run this code?


No.. I didn't do anything extra to run the program except for setting the classpath for jdk... I just gave the normal commands as we do to compile and run any java file in general.

javac -d . Student.java and javac -d . a.java
and to run java course.a

Thats all. No extra commands.

P.S I put "-d ." because my java files were not in course directory.
[ November 14, 2007: Message edited by: Kinnaree Patel ]
 
satabdi das
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


there are no problem with your program. It's an issue with your classpath setting. I have created a directoty under Practice. So I executed the program like this.

java -classpath /Practice/ course.Student

it worked. You need to set your classpath option accordingly.

Hope I helped.

Regards,
Satabdi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic