The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Packages - Accross Files

Posted by karthik on May 18, 2000 at 10:57 PM

Hi,
I have small program which has a base class (class name: "base"), with a defualt constructor wich just prints base's member variable. The scope of this class and the constructor is "Public". I create this in a package "MyPack" and save in a file called base.java.
I have a different file called derived.java which imports the package "MyPack" and it derives from class base. In this class i just print the value of base class value.
I have a third file called "demo.java" which has the main method creating an object of the derived class.
Now i store these 3 files in a directory c:\test\*.java
I want to compile these 3 files and put the resulting .class files in the directory c:\test\MyPack.
The problem i'm facing is : the first file base.java gets compiled and puts the base.class file in
c:\test\MyPack\base.class. Now while compiling derived.java, it gives a error that the "base class is not found".

i compiled like :c:\test\> javac -d c:\test\MyPack\ derived.java

I tried with -classpath option also. It's still giving the same error. How to compile this and what could be reason for the error?





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us