NetBeans error: package org does not exist

2019-02-09 04:48发布

I just installed Netbeans IDE. I am now unable to import any org.* libs and it just says package org does not exist. Also, I imported jdic.jar into the project and even though the code completion suggestions show up as org.jdesktop.*, it shows the same error.

How do I fix this?

4条回答
Anthone
2楼-- · 2019-02-09 05:10

You should redirect all the lost .jar files by exiting netbeans, then reopening it. There should be a prompt asking you to help the IDE find the .jar files. So please do so. If you aren't able to find the jar file. Clean and build the individual packages. There a new directory called a dist directory will be created in the package directory. Now you can redirect them.

查看更多
甜甜的少女心
3楼-- · 2019-02-09 05:11

org.netbeans.lib.awtextra is part of the AbsoluteLayout library. It should be added automatically by the ide whenever absolutelayout is used in the form. But if you switch to some other layout after using absolute layout, then the jar/library will be removed from the classpath and existing code making calls to the library will not compile.

  • If you would like to use absolute layout, then please include the library in the project. Select 'Libraries' node in the project, right-click and select 'Add Library' and select 'Absolute Layout' library from the list of available libraries.

  • If you do not wish to use absolute layout, then it is best to uncomment/remove code relying on the library and re-do the form design using the new layout.

查看更多
成全新的幸福
4楼-- · 2019-02-09 05:16

Can you try importing

import org.xml.sax.Attributes;

This is part of the JDK. If you can't find that, something is really wrong.


I suspect you need to add the libraries to your maven pom.xml file.

查看更多
ら.Afraid
5楼-- · 2019-02-09 05:18

Clearing the cache fixed it. In windows 7 the cache is located in

C:\Users\username\AppData\Local\NetBeans\...

On Linux, the cache is at:

/home/username/.cache/netbeans/...

On clearing the cache, and restarting netbeans, it started to recognize org.* imports again.

查看更多
登录 后发表回答