wood burning stoves*
The moose likes Beginning Java and the fly likes package problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package problem" Watch "package problem" New topic
Author

package problem

simran rao
Greenhorn

Joined: Jun 28, 2004
Posts: 1
hi


i am studying the access modifier chapter from k&b.......i know tht a source file can be put in to a package by including statement in the source code as this....

package mypackage;

but i didnot understand the folder creation for package .......do i need to change my classpath variable.
please help me with a simple eg....such as class one trying to access class two which is in diff pkg.........where will i create the two packages(i mean the absolute path).......
Glenn Castro
Ranch Hand

Joined: Aug 24, 2003
Posts: 78
Here's a simple example on how to access a class on another class which have different packages:

package example;

public class ClassOne {
//code here
}

-------------------
package test;

import example.ClassOne; //use import to use other classes in diff. package

public class ClassTwo {
ClassOne one = new ClassOne();
//other code here
}


Glenn Castro<br />Sun Certified Web Component Developer
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

http://jarticles.com/package/package_eng.html


Groovy
 
 
subject: package problem
 
Similar Threads
Default access modifier. What does it do?
ClassNames
Servlet Compilation
class inheritance and static variable question
One Public Class Per Source File?