This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Import not working?  RSS feed

 
Zachary Anderson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Base.java has "import java.util.*;" as its seventh line.

JBuilder has a number of warnings about unresolved Time statements. The first of which happens in Base.

So when I run MyProgram, the quiz selector opens, but when I tell it to start the quiz (and start timing), black screen, no images.

And we get: "Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems:
Time cannot be resolved to a type (copied 10 times)

at ycb.Base.setup(Base.java:268)..."

And here's line 268 of Base: "t.schedule( new Time ( p1a ), time * 1000 );"
(with Time underlined in red)

The most frustrating part is that JBuilder obviously recognizes that Time is a subclass of java.util, since when I right-click on it and ask for the definition, it opens Time.class (extends Java.util.Date).

Soo... how can I get it to recognize that Time is already declared? I could also copy-and-paste and create my own Time class, but that's both disingenuous and poor practice.

Thank you for your time,
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see a Time class in the
java.util javadoc. You can't import what doesn't exist.
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that there is a Time class which extends java.util.Date. It isn't in the java.util package, though.

If you look in the API documentation which Joe linked to, and go to the page for java.util.Date, you will see a list of classes which extend it. One of them is the Time class which you thought you needed. Follow the link to see what package it's in.

Or alternatively, press the command key which tells JBuilder to generate import statements. (I assume it must have one, I don't use it myself.)
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!