Discussion:
Netbeans bug, and 'Incorrect Package'
Audrey Lee
2010-08-12 19:06:52 UTC
Permalink
Hello List,

I am new to both Java and Netbeans.

I downloaded some Java software off the Net and I am using Netbeans to look at
it.

On one of the files, Netbeans is indicating a problem with the file.

At the very top of the file, the author has placed a package declaration:

package samples.rfq;

Netbeans is using a red-dot to the left of the package declaration to tell me
that it has a problem with the package declaration.

When I mouse-hover the package declaration, Netbeans tells me this:

Incorrect Package
(Alt-Enter shows hints)

On my Mac-keyboard I press Alt-Enter and Netbeans just interprets that as an
Enter (and then I need to undo that Enter).

I have 2 questions:

1. How do I work around the Alt-Enter-bug to see the hints?

2. What do you typically do when Netbeans indicates 'Incorrect Package' on one
of your package declarations?
Mark Wade
2010-08-12 20:19:34 UTC
Permalink
Not a bug. The directory structure where that .java file resides has
to match the package declaration., so given
com.me.mystuff.MyFile.java, the path to MyFile.java should be com/me/
mystuff/MyFile.java and should be contained in the projects source
folder, usually src.

The Alt-Enter key combination is Option-Return on a mac keyboard. The
caret needs to be on the offending line.
Post by Audrey Lee
Hello List,
I am new to both Java and Netbeans.
I downloaded some Java software off the Net and I am using Netbeans
to look at it.
On one of the files, Netbeans is indicating a problem with the file.
At the very top of the file, the author has placed a package
package samples.rfq;
Netbeans is using a red-dot to the left of the package declaration
to tell me that it has a problem with the package declaration.
Incorrect Package
(Alt-Enter shows hints)
On my Mac-keyboard I press Alt-Enter and Netbeans just interprets
that as an Enter (and then I need to undo that Enter).
1. How do I work around the Alt-Enter-bug to see the hints?
2. What do you typically do when Netbeans indicates 'Incorrect
Package' on one of your package declarations?
Mark Wade
***@optonline.net
Alan Stange
2010-08-12 20:42:20 UTC
Permalink
Post by Audrey Lee
Hello List,
I am new to both Java and Netbeans.
I downloaded some Java software off the Net and I am using Netbeans to
look at it.
On one of the files, Netbeans is indicating a problem with the file.
package samples.rfq;
Netbeans is using a red-dot to the left of the package declaration to
tell me that it has a problem with the package declaration.
Incorrect Package
(Alt-Enter shows hints)
On my Mac-keyboard I press Alt-Enter and Netbeans just interprets that
as an Enter (and then I need to undo that Enter).
1. How do I work around the Alt-Enter-bug to see the hints?
2. What do you typically do when Netbeans indicates 'Incorrect
Package' on one of your package declarations?
I listen to what the IDE reports and correct the incorrect package name
or correct the incorrect file name.

-- Alan
Audrey Lee
2010-08-13 00:49:19 UTC
Permalink
I think both the filename and its location is okay.

I think the problem is with Netbeans.

I looked at the file and I see it here in the (Linux) file system:

***@z2:/pt/z2/api$
***@z2:/pt/z2/api$ ls -la /pt/z2/api/samples/rfq/SampleRfq.java
-rw-r--r-- 1 a a 14475 2008-08-13 15:49 /pt/z2/api/samples/rfq/SampleRfq.java
***@z2:/pt/z2/api$
***@z2:/pt/z2/api$


***@z2:/pt/z2/api$
***@z2:/pt/z2/api$ grep package /pt/z2/api/samples/rfq/SampleRfq.java
package samples.rfq;
***@z2:/pt/z2/api$

So obviously it is in a directory which matches its package declaration.

I tried running javac against the file from a variety of directories.

This works:

cd /pt/z2/api/
javac samples/rfq/SampleRfq.java

If I run javac from any other directory it fails.

So, I see a dependency between 3 things here:

- Location of the SampleRfq.java
- Syntax in the package declaration
- Location of the javac command

Since I got javac to work, I'm convinced of 2 things:

- SampleRfq.java is in the correct directory
- Syntax in the package declaration is correct

So, it looks like my issue is with Netbeans.
Netbeans is too ... 'stupid' to know that:

- SampleRfq.java is in the correct directory
- Syntax in the package declaration is correct

How do I help Netbeans?




________________________________
From: Audrey Lee <***@yahoo.com>
To: ***@netbeans.org
Sent: Thu, August 12, 2010 12:06:52 PM
Subject: Netbeans bug, and 'Incorrect Package'


Hello List,

I am new to both Java and Netbeans.

I downloaded some Java software off the Net and I am using Netbeans to look at
it.

On one of the files, Netbeans is indicating a problem with the file.

At the very top of the file, the author has placed a package declaration:

package samples.rfq;

Netbeans is using a red-dot to the left of the package declaration to tell me
that it has a problem with the package declaration.

When I mouse-hover the package declaration, Netbeans tells me this:

Incorrect Package
(Alt-Enter shows hints)

On my Mac-keyboard I press Alt-Enter and Netbeans just interprets that as an
Enter (and then I need to undo that Enter).

I have 2 questions:

1. How do I work around the Alt-Enter-bug to see the hints?

2. What do you typically do when Netbeans indicates 'Incorrect Package' on one
of your package declarations?
Audrey Lee
2010-08-13 01:08:34 UTC
Permalink
ok,

I got the error to evaporate.

steps:

1. abandon my netbeans project
2. rsync my code to a new directory; create new NB project; (NB will not let me
use old code)
3. right-click-project: select properties
4. Add folder
5. Pick the parent of the directory corresponding to the package

Netbeans now "knows" that the package declaration matches the directory
structure.




________________________________
From: Audrey Lee <***@yahoo.com>
To: ***@netbeans.org
Sent: Thu, August 12, 2010 5:49:19 PM
Subject: Re: Netbeans bug, and 'Incorrect Package'


I think both the filename and its location is okay.

I think the problem is with Netbeans.

I looked at the file and I see it here in the (Linux) file system:

***@z2:/pt/z2/api$
***@z2:/pt/z2/api$ ls -la /pt/z2/api/samples/rfq/SampleRfq.java
-rw-r--r-- 1 a a 14475 2008-08-13 15:49 /pt/z2/api/samples/rfq/SampleRfq.java
***@z2:/pt/z2/api$
***@z2:/pt/z2/api$


***@z2:/pt/z2/api$
***@z2:/pt/z2/api$ grep package /pt/z2/api/samples/rfq/SampleRfq.java
package samples.rfq;
***@z2:/pt/z2/api$

So obviously it is in a directory which matches its package declaration.

I tried running javac against the file from a variety of directories.

This works:

cd /pt/z2/api/
javac samples/rfq/SampleRfq.java

If I run javac from any other directory it fails.

So, I see a dependency between 3 things here:

- Location of the SampleRfq.java
- Syntax in the package declaration
- Location of the javac command

Since I got javac to work, I'm convinced of 2 things:

- SampleRfq.java is in the correct directory
- Syntax in the package declaration is correct

So, it looks like my issue is with Netbeans.
Netbeans is too ... 'stupid' to know that:

- SampleRfq.java is in the correct directory
- Syntax in the package declaration is correct

How do I help Netbeans?




________________________________
From: Audrey Lee <***@yahoo.com>
To: ***@netbeans.org
Sent: Thu, August 12, 2010 12:06:52 PM
Subject: Netbeans bug, and 'Incorrect Package'


Hello List,

I am new to both Java and Netbeans.

I downloaded some Java software off the Net and I am using Netbeans to look at
it.

On one of the files, Netbeans is indicating a problem with the file.

At the very top of the file, the author has placed a package declaration:

package samples.rfq;

Netbeans is using a red-dot to the left of the package declaration to tell me
that it has a problem with the package declaration.

When I mouse-hover the package declaration, Netbeans tells me this:

Incorrect Package
(Alt-Enter shows hints)

On my Mac-keyboard I press Alt-Enter and Netbeans just interprets that as an
Enter (and then I need to undo that Enter).

I have 2 questions:

1. How do I work around the Alt-Enter-bug to see the hints?

2. What do you typically do when Netbeans indicates 'Incorrect Package' on one
of your package declarations?
Mark Wade
2010-08-13 03:24:29 UTC
Permalink
Oh.

NetBeans projects default with a source location of {project
directory}/src. I thought that was configurable in the "New Project"
wizard but apparently it isn't. If you want a different location for
source files you have to set it in the project's properties after the
wizard completes. So, the package declaration:

package samples.rfq;

is correct, but the source resides in:

/pt/z2/api

Apparently at this point the source location was still set to:
{project directory}/src
Post by Audrey Lee
3. right-click-project: select properties
4. Add folder
The first node in the Categories tree is "Sources:" Adding /pt/z2/api
to the "Source Package Folders" table allowed NetBeans to properly
resolve the package declaration.

Steps three and four would have probably corrected the error in the
original project.

I thought NetBeans allowed input as to where to locate sources when a
project is created but either that has changed or my recollection is
incorrect.
Post by Audrey Lee
ok,
I got the error to evaporate.
1. abandon my netbeans project
2. rsync my code to a new directory; create new NB project; (NB will
not let me use old code)
3. right-click-project: select properties
4. Add folder
5. Pick the parent of the directory corresponding to the package
Netbeans now "knows" that the package declaration matches the
directory structure.
Sent: Thu, August 12, 2010 5:49:19 PM
Subject: Re: Netbeans bug, and 'Incorrect Package'
I think both the filename and its location is okay.
I think the problem is with Netbeans.
-rw-r--r-- 1 a a 14475 2008-08-13 15:49 /pt/z2/api/samples/rfq/
SampleRfq.java
package samples.rfq;
So obviously it is in a directory which matches its package
declaration.
I tried running javac against the file from a variety of directories.
cd /pt/z2/api/
javac samples/rfq/SampleRfq.java
If I run javac from any other directory it fails.
- Location of the SampleRfq.java
- Syntax in the package declaration
- Location of the javac command
- SampleRfq.java is in the correct directory
- Syntax in the package declaration is correct
So, it looks like my issue is with Netbeans.
- SampleRfq.java is in the correct directory
- Syntax in the package declaration is correct
How do I help Netbeans?
Sent: Thu, August 12, 2010 12:06:52 PM
Subject: Netbeans bug, and 'Incorrect Package'
Hello List,
I am new to both Java and Netbeans.
I downloaded some Java software off the Net and I am using Netbeans
to look at it.
On one of the files, Netbeans is indicating a problem with the file.
At the very top of the file, the author has placed a package
package samples.rfq;
Netbeans is using a red-dot to the left of the package declaration
to tell me that it has a problem with the package declaration.
Incorrect Package
(Alt-Enter shows hints)
On my Mac-keyboard I press Alt-Enter and Netbeans just interprets
that as an Enter (and then I need to undo that Enter).
1. How do I work around the Alt-Enter-bug to see the hints?
2. What do you typically do when Netbeans indicates 'Incorrect
Package' on one of your package declarations?
Mark Wade
***@optonline.net

Loading...