Already imported the jar files in netbeans but my source cannot find the library

10,881

I also had problem with importing classes from imported jar. It was so damn annoying...

There are couple solutions @ web, (clear cache in user's AppData. or make sure to add jar's properly - by using "Add Jar/Folder..." option) but none of them worked for me.

What worked was new project and importing THE SAME (that's sad) jar files into it. So I had 2 project with exactly the same contents, but only one of them was working (compiling).

EDIT: However, your problem is not related to mine. Root cause of your issue is the jar itself.

It contains class files in default package that is making them impossible to import.

Read here how to import class from default (unnamed) package.

Share:
10,881
jax
Author by

jax

Updated on June 04, 2022

Comments

  • jax
    jax almost 2 years

    I already imported the jar files in netbeans but my main java file still cannot find the methods. I am using netbeans 7.3.1 on Mac. Does anyone know how make it work?

    Thank you,

  • jax
    jax over 10 years
    I am new to java environment. I added the stdlib.jar from project properties -> libraries ->compile -> add jar folder. For instance there is a StdIn.java in that library. I tried to import it using import StdIn.java; and it tells me StdIn.java does not exist.
  • dantuch
    dantuch over 10 years
    @arashaga try with import StdIn;
  • dantuch
    dantuch over 10 years
    where you get that jar from?
  • Scott Barta
    Scott Barta over 10 years
    Putting jar files inside your Java installation is a bad idea.
  • user3217883
    user3217883 almost 7 years
    What worked for me was to close NetBeans and re-open it.