This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 239243 - [Rename] Add option to rename subpackages
Summary: [Rename] Add option to rename subpackages
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.4
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Ralph Ruijs
Depends on:
Reported: 2013-12-08 15:37 UTC by luigiusai
Modified: 2015-07-29 23:58 UTC (History)
2 users (show)

See Also:
Exception Reporter:

IDE log (51.56 KB, text/plain)
2013-12-08 15:37 UTC, luigiusai
Screenshots of the bug (633.27 KB, application/zip)
2013-12-11 15:45 UTC, luigiusai

Note You need to log in before you can comment on or make changes to this bug.
Description luigiusai 2013-12-08 15:37:03 UTC
Product Version = NetBeans IDE 7.4 (Build 201310111528)
Operating System = Linux version 3.2.0-38-generic running on amd64
Java; VM; Vendor = 1.7.0_45
Runtime = Java HotSpot(TM) 64-Bit Server VM 24.45-b08

Hi, I am Luigi Usai, from Verona University, Italy.
Procedure for recreating the bug:

1) I have a project, let's suppose Mediathek View

2) I want to refactor the projct calling it MultimediaOnline instead of Mediathek

3) While refactoring the project, Netbeans 7.4 create a new directory and moves the .java files inside, 
but not the other subdirectories.

4) this way, the project stops compiling, signalling there are missing res files (from the /res/ directory, which still is on the previous place)

Copying 1 file to /home/studente/src/MultimediaOnline/build/classes
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at javax.swing.ImageIcon.<init>(
	at mediathekview.MediathekGui.initComponents(
	at mediathekview.MediathekGui.<init>(
	at mediathekview.Main$
	at java.awt.event.InvocationEvent.dispatch(
	at java.awt.EventQueue.dispatchEventImpl(
	at java.awt.EventQueue.access$200(
	at java.awt.EventQueue$
	at java.awt.EventQueue$
	at Method)
	at java.awt.EventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(
BUILD SUCCESSFUL (total time: 2 seconds)
Comment 1 luigiusai 2013-12-08 15:37:08 UTC
Created attachment 142946 [details]
IDE log
Comment 2 Jiri Prox 2013-12-11 12:31:08 UTC
Sorry but I cannot reproduce the wrong behavior with the sources downloaded from source forge. 

Can you provide your project?
Comment 3 luigiusai 2013-12-11 15:43:57 UTC
Yes, I can provide 2 things:

1) my sources:

at this page:

the version

2) the screenshot of the bug:

Let me know if you need more specifications about it.

Best regards
Comment 4 luigiusai 2013-12-11 15:45:51 UTC
Created attachment 143070 [details]
Screenshots of the bug

I add you the screenshots of how to replicate the bug.
Comment 5 Jiri Prox 2013-12-11 16:13:19 UTC
Thanks, I can see the problem now

When renaming package "mediathek" all references to resources in package "mediathek.res" generated by from editor are also changed although the subpackage was not renamed 

e.g.: getClass().getResource("/mediathek/res/film_rec_16.png") is changed to
Comment 6 Tomas Pavek 2013-12-11 18:13:43 UTC
Maybe I do not understand it, but it seems to me the reporter actually wants to rename the whole tree, complaining that NB creates a new directory "and moves the .java files inside, but not the other subdirectories". In this sense the GUI builder renamed the resources well (as what was expected), the problem is that the rest of refactoring did not rename everything.

Can you advise how to do the whole dir rename?
Comment 7 luigiusai 2013-12-23 18:44:42 UTC
Tomas Pavek, you are right.
Let's suppose I have:


the node "geometry" is a directory containing java classes.
If NB renames only one package, software stops compiling.
This behaviour is an error.

IMHO, NB should rename each node "geometry".
Thank you.
Comment 8 Ralph Ruijs 2013-12-24 11:30:43 UTC
In java there is no notion of subpackages. Renaming a folder is done through the files view.
Comment 9 luigiusai 2013-12-24 11:52:51 UTC
I'm sorry if I must reopen this bug. I'm going to explain why.

Source of information is this book: Ken Arnold, James Gosling, David Holmes, The Java Programming Language, Fourth Edition, Addison-Wesley Professional, 2005, ISBN 0-321-34980-6; James ...

James Gosling invented Java, so I think you'll trust him. ;)

In the Italian third edition of this book, chapter 20.9, they teach the Java Subpackages.

Please I ask you to reconsider this bug for the sake of Netbeans.
Comment 10 luigiusai 2013-12-24 12:04:41 UTC
If this can be useful, you can look here for detailed info:

I searched over the internet for your sentence:

"in java there's no notion of subpackage"

I got about 473.000 results (0,59 seconds)

It's very sad, because it means that online there's lot of people talking without knowledge. Sometimes internet is not trustable, unless you do a deeper search.
Thank you all, programmers.
Comment 11 Ralph Ruijs 2013-12-26 12:21:54 UTC
(In reply to luigiusai from comment #9)
> I'm sorry if I must reopen this bug. I'm going to explain why.

You are right. We can add an option to rename subpackages when renaming a package.
Comment 12 luigiusai 2015-07-29 23:58:15 UTC
Tested on 
NetBeans IDE 8.0.2
Windows 8 version, 64 bit

the problem still exists in the last Netbeans version.

Let's make a simple example:

create a new project with the Netbeans from samples:
Samples --> JavaFX --> BrickBreaker

Now refactor the main program name

refactor BrickBreaker --> newProgramName;

this command should rename both the main program AND all the subpackages.

This first bug generate a second bug: if you try to restore the original name, Netbeans says "The package already exists" and user get stuck.

There are two bugs in one.

More info and screenshots here:

Best regards and thank you all for your efforts to build a better tool.

Luigi, Verona