简体   繁体   中英

“The import java.awt cannot be resolved” and “ ***** cannot be resolved to a type”

I downloaded a Java project that I want to study and learn some things from. When I downloaded it on another computer it worked great, but when I try it on my computer, nearly every declaration and import is given the error message " * cannot be resolved to a type" or "The import java.awt cannot be resolved".

I did some research on this site and found that it might have to do with not having the latest Java installed. I checked mine, and I have JavaSE-1.7 (unbound). So I have the latest version but it's (unbound)?

Can this be the problem? And what does (unbound) mean?

I'm using Eclipse 3.3.2

UPDATE: I just found this error message at the top of the Properties window: org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7 . What does this mean?

This occurs because project has dependency on library of J2SE 1.7 but it cannot find JRE at that location in your machine.

Project->Properties->Java Build Path

Or Add a new JRE in eclipse using Window>Preferences>Java>Installed JRE and locate the path of the JRE folder in your machine. and then replace the dependency of your project with the new JRE you installed in eclipse.

UPDATE UNBOUND JRE in Hello World

This may work for some... it did for me:

  1. Hover over "java.awt" in your code, and under quick fixes available , select Fix Project Setup .

  2. Pop-up displays saying " The following proposals have been found... " and
    " Add Library JRE System Library[JavaSE-1.7] to build path " is selected.

  3. Select Ok.

Problem occurs because project has dependency on library of java 1.7 but it cannot find JRE at specified location in your machine.

Project->Properties->Java Build Path

Or Add a new JRE in eclipse using Window>Preferences>Java>Installed JRE and locate the path of the JRE folder in your machine. and then replace the dependency of your project with the new JRE you installed in eclipse. if teher is No JRE and click on add jre tab and provide the directory location of the Jre and add that.

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