Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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: 39054
714
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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: 57
  • Mark post as helpful
  • send pies
  • 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: 39054
714
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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: 57
  • Mark post as helpful
  • send pies
  • 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: 39054
714
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's fixed! Thank you so much for your help!
 
Jeanne Boyarsky
author & internet detective
Posts: 39054
714
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!