File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package" Watch "package" New topic
Author

package

rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
I have read at the sun site that Java runtime system automatically imports three entire packages:
The default package (the package with no name)
The java.langpackage
The current package
What does it mean by the default and the current pacakge?


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
The definition of "current" directory is dependant on the host system.
In windows, the current directory IS the default (un-named) package and is the directory that you are sitting in when you compile. Therefore if there is any other class file in the same directory with you, you can access it without explicetly importing it.
(edited by Cindy to change "package" references to "directory" references )

[This message has been edited by Cindy Glass (edited May 17, 2001).]


"JavaRanch, where the deer and the Certified play" - David O'Meara
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
you mean to say that the current and default package is same.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I don't understand the meaning of current package as you. But for me if you have a class in the package com.stuff you do not need to import classes from this package inside your code. Thus for me the current package is the package where your class is declared.
For default package it seems to me that it is classes without package definition.
If i'am wrong tell me what i miss
------------------
Benjamin l´┐Żonard
evisor
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You are correct, the current package is the one that the class is in. I intended to talk about the current directory and completely muddled it. Thanks for pointing it out.
From the JLS 7.4.2 Unnamed Packages

An implementation of the Java platform must support at least one unnamed package; it may support more than one unnamed package but is not required to do so. Which compilation units are in each unnamed package is determined by the host system.
In implementations of the Java platform that use a hierarchical file system for storing packages, one typical strategy is to associate an unnamed package with each directory; only one unnamed package is observable at a time, namely the one that is associated with the "current working directory." The precise meaning of "current working directory" depends on the host system.
Unnamed packages are provided by the Java platform principally for convenience when developing small or temporary applications or when just beginning development.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: package