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

Java Import funtion...

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


    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 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 Posts: 2,228 ✭✭✭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 Posts: 6,306 ✭✭✭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 Posts: 2,228 ✭✭✭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 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 Posts: 6,306 ✭✭✭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