views:

11

answers:

1

orig post:

Hello List,

I am new to Java, Netbeans, and the IB Java API.

I downloaded the IB Java API software 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:

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

What do you typically do when Netbeans indicates 'Incorrect Package' on one of your package declarations?

My comment to Josefx:

josefx,

I think maybe you gave me a good clue.

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

a@z2:/pt/z2/api$ a@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 a@z2:/pt/z2/api$ a@z2:/pt/z2/api$

a@z2:/pt/z2/api$ a@z2:/pt/z2/api$ grep package /pt/z2/api/samples/rfq/SampleRfq.java package samples.rfq; a@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?

I posted a question to the Netbeans mail-list and the only answer I got was: "Fix the incorrect file name".

A: 

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.

Audrey Smith