Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java Import funtion...

  • 10-03-2007 2:46am
    #1
    Registered Users, Registered Users 2 Posts: 2,236 ✭✭✭


    Hi,
    Just after beginning to learn Java but I have ran into a problem..
    Can someone explain the import function as seen below please.. I have two books out from the library and in both books their examples use this function. the book says to download these packages from their websites but the books are so old now that that the URLs aren't live anymore..does this mean that the book is useless or just parts of it?
    How do I go about setting up these packages so they can be called etc..??

    Thanks


    //************** beginning of code ***********************

    import javabook.*;


    public class program


Comments

  • Registered Users, Registered Users 2 Posts: 8,449 ✭✭✭Call Me Jimmy


    If ye have the java sdk installed (if ye're compiling and running programs that work then ye do) then ye don't need to download anything. The function itself is simply telling java that you want to use classes from those standard packages.

    For example, java.net package contains useful classes for network coding etc.
    Also the .* tells it to import ALL classes in that package.

    I'm not entirely sure if that's what ye wanted to know tho


  • Registered Users, Registered Users 2 Posts: 2,236 ✭✭✭techguy


    I think I gave a bad example so. See the edited version now. the packafge I wanted to inport is a third party packaget that I downloaded from the authors site.. hwo would I go about setting that up??


  • Registered Users, Registered Users 2 Posts: 6,334 ✭✭✭OfflerCrocGod


    techguy wrote:
    hwo would I go about setting that up??
    I presume you are new to programming? Is this book a few years old? I don't think it's a good idea to use a book for beginners that asks you to import classfiles because that usually means it's hiding some coding from you in an effort to make it "easier" for you. Don't bother with the book get yourself a newer Java book. If you really want to go ahead and use this book though just stick the classfiles in the same directory as the code you are running; I also suggest having a quick read though this tutorial.


  • Closed Accounts Posts: 2,279 ✭✭✭DemonOfTheFall


    What IDE are you using ?

    If it's Eclipse, for example, you'd right click on your project, go to "Configure Build Path" and select "Add external JAR". Then you select the package you downloaded. Eclipse will make this downloaded file part of your project and when you import it everything will work fine.


  • Registered Users, Registered Users 2 Posts: 2,236 ✭✭✭techguy


    Yes I am completely new to programming, with the exception of a bit of QBasic...I am looking into getting a newer book, anybody tried Head First Java (2nd Ed)?? I am going to try and source this..
    Also, I am using NetBeans IDE..

    Another quick question.. Is it okay to begin with an IDE and have them help you with syntax or is it better to start from nothing like using a text editor such as Notepad++ ?? Just a thaught that you might only be learning 70% of the language with an IDE, no??


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Depends. there is a learning curve on learning the IDE as well.

    If your going to be studying for exams or something its best to get familar with doing everything at the command line/notepad before falling back to an IDE.

    You learn all the language with the IDE. The problem with the IDE is that it will repair/change stuff to a layout that is best and you won't know why. Or it will catch simple stuff easier which you might not learn yourself in notepad.


  • Closed Accounts Posts: 362 ✭✭information




  • Registered Users, Registered Users 2 Posts: 6,334 ✭✭✭OfflerCrocGod


    techguy wrote:
    Another quick question.. Is it okay to begin with an IDE and have them help you with syntax or is it better to start from nothing like using a text editor such as Notepad++ ?? Just a thaught that you might only be learning 70% of the language with an IDE, no??
    If you are starting from scratch then I would suggest using simply an editor like SciTE and move onto IDEs once you are building programs with more then one or two classes.


Advertisement