简体   繁体   中英

Jar file not loading in eclipse

I created a jar file and would like to implement it into my other projects. However, I am getting an error "cannot be resolved to a type." I added the .jar file to the Build Path Libraries within eclipse but the error persists.

EDIT: I tried following the tutorial here: http://www.programcreek.com/2011/07/build-a-java-library-for-yourself/

However, this still does not work.

System.out.println(Simple.add(1,2));

I get the error "Cannot be resolved" on the Simple class name.

EDIT:

package TEST;
public class AccessSimple
{
   public void access()
   {
      System.out.println(Simple.add(1, 2));
   }
}

Here is the class I am using to access my jar file. It is not part of the default package.

Try to do a refresh in the project to see if it works then. Otherwise try clean. Then build and refresh. Finally perform a restart of eclipse

EDIT I read somewhere that if you try Windows–>Preferences–>Java–>Compiler–>Building–>Output folder–>”Rebuild class files modified by others” will work. Give it a try and tell me to search better

Check the "Java Complier" version used to build the jar file against the "Java Compiler" version of your project. If the jar you are including was built with a higher version than the compiler version of your project, the compiled class might not be found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM