I'm using IntelliJ 11.1.3 and I'm trying to attach two external libraries in the form of jarfiles to use in a module. I've added them in project structure -> module -> dependencies and they show up correctly under libraries as well, but I can't import them in my source code.
Is there a step I'm missing here? I'm pretty new to IntelliJ, having used Netbeans exclusively before, so I'm a little lost. I thought it would be simple enough to attach the external libraries and use the classes immediately, but I don't even get the library names on code completion when I type 'import'.
To avoid IntelliJ IDEA replacing imports with * , you need to configure the Class count to use import with '*' and Names count to use static import with '*' preferences: Go to Preferences > Editor > Code Style > Java.
You are doing it right, libraries are configured in the Module Dependencies. Verify that the correct files were added there.
You should be able to browse inside the jars in the Project View under Libraries node. If you can't see the jars there, then your library is not configured properly. If you see the jars, but can't see classes inside of them, they are probably broken, replace them with the valid copies.
Also check that the libraries are added to the dependencies of the correct module where you try to import and use them. Verify the scope of the dependency, Compile is most likely what you need.
File
| Invalidate Caches may help in case everything looks correct, but doesn't work.
If nothing helps, please share a sample project with the libraries to illustrate the issue.
You're using a package. These libraries are to be used from the default package. So, move all your classes to the default package (i.e. the src folder) and remove all package/import statements. Also, instead of java.io, use the In or Stdin classes to read the data.
I met this problem too, what i did is close current project and recreate/import the project and then import jars, and it works. I know its not wise ,but it's a direct and simple way. As i tried all the thing CRAZYCODER said but not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With