soham.m17 soham.m17 - 3 months ago 8
Java Question

Adding Default Package's Classes in NetBeans

I have a jar file named

"stdlib.jar"
. This has many classes in its
"Default Package"
. I have added this
stdlib.jar
to my NetBeans Libraries. and Also
"Build"-ed
it without using anything from
stdlib.jar
. So that
stdlib.jar
can be added to my
"./dist/lib"
folder. But still I can't use any classes within
stdlib.jar

What should I do to reuse any classes within
stdlib.jar
?

Answer

Using "Default Package" package for libraries or even for a project is highly discouraged. If you use default package then the classes name should be unique or else they will override all the java.lang classes.

Now coming to your situation. To use your stdlib.jar if you've added it in your library then you should be able to use it. You can use your stdlib.jar from your default package of the project in which you are using it. Other than default package you cannot use it as it will search your stdlib.jar class in that package.

Hope this makes you clear. Thanks.