Netbeans 6.8: Lib-Import works, but "package does not exist" when compiling
I'm working on a JavaME project and need to import external libraries, which are available to me as jar files. So I selected the project properties -> libraries & resources -> add Jar/Zip and added the jar file there.
When editing the code, everything works. I can import the classes from this library and use them as expected. But when I try to compile the project, I'm getting the error...
package <packagename> does not exist
...at the line
import <packagename>.<classname>;
Like I said, no error or warning shows up when editing the code. The library is correctly shown in the project开发者_运维知识库 view under "Resources" and the Netbeans autocomplete works as well. The error occurs only when compiling.
Once in a while the ant script (nbproject/build-impl.xml) will get out of sync with the project (nbproject/project.properties). This is easily fixed by makinga another change to the project to encourage NB to rewrite the ant script.
Open the project properties dialog (File > Project properties) and select Compiling
. Toggle the state of Compile on Save
. Click OK
to close the dialog and rewrite the ant script. Give it a moment to be sure it's not busy scanning the project (Status displayed in the bottom right.) Then open the dialog again and toggle the value back. Close the dialog and try compiling again.
精彩评论