• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Imports in Java Eclipse errors. "Java.awt" and "Javax.swing" cannot be resolved? Help?

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good evening! I'm trying to complete the drawCircles() class included below so that it will draw 9 or more circles in a row in Java Eclipse. The start up program only draws the first and smallest circle, but this isn't where the error I'm trying to fix stems from. At the beginning of my class, there is a list of imports-

On each of these lines, I am receiving this error: "The import java.awt cannot be resolved." A similar error appears in my other class of this code on the import-

On this line, the error is "The import "javax.swing" cannot be resolved." How can I fix these errors? Thank you! (Full code included below)

Class 1-

Class 2-

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you add


I think you'll get the same error. If so, that confirms it has nothing to do with AWT/Swing and is that Java itself isn't being found. What IDE are you using? Eclipse? IntelliJ? Netbeans? Other?
 
Jeremiah Waters
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added java.util.ArrayList (as shown in the attached picture), but I didn't receive any error this time. I'm using Eclipse.
Thank you for the help!
Screen-Shot-2018-12-19-at-6.53.25-PM.png
[Thumbnail for Screen-Shot-2018-12-19-at-6.53.25-PM.png]
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that's interesting. Can you check a setting in Eclipse for me in the preferences?

Right click your project and choose properties. Then go to Java Build path. There should be something there about the version of Java. What does it say? (For example Java SE 1.8).

Then go to the Eclipse overall preferences (under the window pull down on Windows or the Eclipse pull down on Mac). Go to Java > Installed JREs. What does it say the location of that version of Java is?
 
Jeremiah Waters
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!

1) It says that I have JavaSE-10.

2) On preferences, it says that my locations is /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Content... (I can't get it to expand to see the full location, sorry. I'm using a Mac if that helps.)
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's enough. I was checking you were using a JDK (and not a JRE). You are good.

This post suggests you need to enable the desktop module explicitly in Java 10.
 
Jeremiah Waters
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's fixed! Thank you so much for your help!
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeremiah Waters wrote:It's fixed! Thank you so much for your help!


Excellent! Could you post a screenshot of what worked?

I hardly ever use awt/swing so it is a good opportunity to learn something.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic