• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

package concept in java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 Foo.java it is available under directory D:\rram
public class Foo {
public Foo() { System.out.println("Foo"); }
}
It will compile Success
another file Name is Bar.java 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:
Bar.java:4: Class Foo not found in import.
import Foo;
^
1 error
can any one help me to solving this problem
regards
ramanarayanan
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raman,
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 Bar.java!
Hope this helps,
Ashok.
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic