Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

what is an unnamed package...  RSS feed

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi :
I was just studying for the SCJP 1.4 exam..and reading some of the reference notes online...and it says:

# if no package declaration is found, the class or interface is made part of an unnamed package
# every implementation of Java must provide for at least one unnamed package
# most systems allow for one unnamed package per directory

i know that if you are running Windows..then java packages are in the form of directories...if the package is name. but what about if the package is not named...for example..you dont declare the package in your class file, that will compile as well..but then what is the "unnamed package" then in this case??

plz lemme know

many thanks

please let me know
 
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by dog lin:


# if no package declaration is found, the class or interface is made part of an unnamed package



If there is no package statement ( must be first line if there is ) in your source file it means that you are working in default project .

For more detail if your source file is in bin folder then you will compile your file like this :

javac MyFile.java

and run like this :

java MyFile

And if suppose your have myPackage in the begining of your source file , then in the bin folder you may create one folder with name myPackage & put your source file in that folder .

for compilation :

javac myPackage/MyFile.java

for execution :

java mypackage.MyFile


hope i have given lots of unnecessary details ...

[ January 08, 2005: Message edited by: rathi ji ]
[ January 08, 2005: Message edited by: rathi ji ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!