Post by PatBatemanWhy can't I rename the default package? How do I get around this in my
code? I need to reference the default package.
Hi,
It is advised that a java project should have proper package hierarchy. We
should not have classes in default package.
The default package in NetBeans is just a placeholder to show all the
classes which are not kept in any package. We cannot import (reference)
classes in default package into classes inside packages. It is a compile
time error doing so. [1]
You can somehow do this anyway by using reflection, but if you just want to
use those classes it is advisable to move them to a package. NetBeans IDE
has good support of moving classes to another package. The steps will be to
create a new package of your desired name and then move the desired class
from the default package into that newly created package.
Once you have the class in a package it can be imported (referenced) in any
class inside another package.
[1]
http://stackoverflow.com/questions/2193226/how-to-import-a-class-from-default-package
--
with regards
Tushar
Tushar Joshi, Nagpur: http://www.tusharvjoshi.com
* MCSD_NET C#, SCJP, RHCE, ZCE, PMP
* Principal Architect: http://www.persistentsys.com
* NetBeans Dream Team Member: http://dreamteam.netbeans.org
* DZone Most Valued Blogger: http://netbeanside61.blogspot.com
* Java User Group Nagpur Leader: http://www.jugnagpur.com
* LinkedIn: http://www.linkedin.com/in/tusharvjoshi