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

package concept in java


Joined: Sep 08, 2003
Posts: 3
Hi Friends,
Don't mistake me.This is small doubt for you.i need one clarification from you regarding package concept in java.
I have develop the sample class called it is available under directory D:\rram
public class Foo {
public Foo() { System.out.println("Foo"); }
It will compile Success
another file Name is it is available under directory D:\rram
package com.test;
import Foo;
public class Bar {
public Bar() { System.out.println("Bar"); }
public static void main(String[] args) {
Bar bar = new Bar();
Foo foo = new Foo();
I have try to compile this program i got the Following error: Class Foo not found in import.
import Foo;
1 error
can any one help me to solving this problem
Ashok Mash
Ranch Hand

Joined: Oct 13, 2000
Posts: 1936
You are trying to import a class, which doesnt belong to any package. This is not the correct usage of classes and packages.
One way to fix your problem is define a package for Foo class and then compile with -d option (to create the correct package structure), and once you have xxx.Foo.class, you need to add the folder where your xxx folder is, into your class path, and then you can try importing it into your!
Hope this helps,

[ flickr ]
I agree. Here's the link:
subject: package concept in java
It's not a secret anymore!