Reputation: 1
the problem is this (import java.*;). i've been watching some tutorials in youtube about frames and etch. and ive been copying his code. i wonder why this happens only in me. I use BlueJ for my IDE and the error says package javax doesnt exist. please help me. Thank you!
well, java.* ; doesnt exist? what's the problem? the guy no youtube has no problem running his code and i copied it carefully without mistake. the only error i get is the line 1 which is: import java.*; same as the guy on youtube.
Upvotes: 0
Views: 131
Reputation: 106470
There's nothing in the top level java
folder for you to import. I'm willing to suspect that the code shown on YouTube is also incorrect if it makes reference to import java.*;
.
Here's why.
Packages are nothing more than folders. In order for a top level package to be able to conduct an import like that, there has to be a compilation unit somewhere in that folder. This means, in layman's terms, there has to be something that can be compiled before that entire directory can be imported.
For example, assume that I have a package structure com.latlonproject.project1
. If I wanted to import everything from this package, I'd have to refer to it as import com.latlonproject.project1.*
, since all of the source in this project lives under project1
. If I had another project with a package structure bar
, then I could do import bar.*
, since all of my compilable source code lives there.
Something has to be compiled in that folder for the wildcard import to work. It won't work any other way.
(Likely for good reason; if you could just do that, then your program would have classes it didn't even need at runtime, likely bloating your application unnecessarily.)
Upvotes: 1