Computer Science Canada

importing packages

Author:  cool dude [ Sun May 07, 2006 10:41 am ]
Post subject:  importing packages

i'm trying to import a package into java, but it says package does not exist. although i see on many other java programs made that they imported it and without this package the program won't run. this is the package i want to import

code:

import hsa.Console;


i could import other packages but for some reason i can't import this one. maybe i have to download this package so does anyone know the site where i can download it?

Author:  cool dude [ Sun May 07, 2006 10:54 am ]
Post subject: 

nevermind i think its just like Scanner to get the user input so i can just change it to import java.io.*; and use the BufferedReader instead.

Author:  rizzix [ Sun May 07, 2006 1:24 pm ]
Post subject: 

In java you do not import Packages. You only import Classes.

You may import one specific class from a package, or all the classes from a package (using *).

Author:  cool dude [ Sun May 07, 2006 5:50 pm ]
Post subject: 

rizzix wrote:
In java you do not import Packages. You only import Classes.

You may import one specific class from a package, or all the classes from a package (using *).


oh srry didn't know Embarassed do u know why i can't import the console class or the scanner class? i got the latest version i think from the java sun website.

Author:  wtd [ Sun May 07, 2006 6:30 pm ]
Post subject: 

The HSA stuff is specific to Ready To Program. I would suggest ignoring it unless a class forces you to use it.

As for Scanner, as long as you have JDK 1.5.0.x you sould be able to import java.util.Scanner.

Author:  Onega [ Mon May 08, 2006 4:28 am ]
Post subject: 

If you want to import some package, that package must be reachable by your program. Usually you have to change your CLASSPATH.[/b]


: