File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes package question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package question" Watch "package question" New topic

package question

cornel jew
Ranch Hand

Joined: Jul 13, 2002
Posts: 37
Hi all
I am busy going through packages, but i have problems compiling the following code.Although A is compiling without any problems B is giving me the following error: package packages does not exist
import packages.*;
^ cannot access A
bad class file: .\
file does not contain class A
Please remove or make sure it appears in the correct subdirectory of the classpath.
{ A a = new A();
I saved the two files in d:\packages,cos my jdk is installed
on the D:\ drive.I also tried to save in a sub directory of packages ,but that also did not work.
My classpath is as follows and i am using Win98:
PATH C:\WINDOWS;C:\WINDOWS\COMMAND;d:\j2sdk1.4.1_01\bin;%PATH%
I don't know if it is correct, cos i have read somewhere to do it this way.
Here is the code:
package packages;
public class A

import packages.*;
public class B
{int b;

public static void main(String args[])
{ A a = new A();
System.out.println("Starting B");
I don't know if i am doing it right, so please help.
Greg Charles

Joined: Oct 01, 2001
Posts: 2968

Hey Cornel Jew,
Wow, cool name! Far above Cayuga's waters ... at least someone is lighting a minora!
Well, anyway, A is in package packages. B is just in the default package. You should pick a directory, say c:\tmp, and put in that directory. Then make a directory c:\tmp\packages and put in there. From c:\tmp, do your classpath thing to get the current directory into the classpath. Now here's the trick, compile both classes at once:
javac packages\
Then, you can run it with:
java B
I agree. Here's the link:
subject: package question
It's not a secret anymore!