Results 1 to 7 of 7
  1. #1
    Sparky is offline Member
    Join Date
    Jan 2011
    Posts
    32
    Rep Power
    0

    Default import statement

    Greetings,

    I am trying some sample code.

    the import statements I see at the top of code - are those similar to the "include" statements for header files?

    Should I be able to find a file corresponding to a name in the importstatement?

    I am getting an error on one of my import statements stating the file does not exist.

    Help?
    Thanks
    Sparky

  2. #2
    Vase is offline Member
    Join Date
    Jan 2011
    Location
    Gainesville, FL
    Posts
    45
    Rep Power
    0

    Default

    Yes, they are similar.

    Java Code:
    import java.util.Scanner;
    You are importing the Scanner class, which is found in package java.util.
    A list of what packages come with Java's API can be found here: Java 2 Platform SE v1.4.2

  3. #3
    Sparky is offline Member
    Join Date
    Jan 2011
    Posts
    32
    Rep Power
    0

    Default

    The import statement that is "failing" is:

    import org.jdom.JDOMException;

    where should this file be located?

    Thanks again
    -Sparky

  4. #4
    Vase is offline Member
    Join Date
    Jan 2011
    Location
    Gainesville, FL
    Posts
    45
    Rep Power
    0

    Default

    If you look at the link, you can browse through all packages and classes provided by Sun, the original API. Users can also create or download their own packages and classes for personal use.

    Looking through the packages, Java does not come with org.jdom, which leads me to believe that it is something you need to find on your own before you can import it.

  5. #5
    Sparky is offline Member
    Join Date
    Jan 2011
    Posts
    32
    Rep Power
    0

    Default

    I have found it at a website and downloaded a *.zip file.

    I am using NetBeans - I have tried (within NetBeans) to go: tools - JAVA Platform - JAVADOC - add zip file.

    No luck with that attempt.

    I do see the file burried several directories down within the zip file.

    Thoughts?

    Thanks
    Sparky

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    You need to add the file(s) to your classpath. This is a Netbeans problem, search the help feature. I'm not sure if netbeans can handle zip files so you may need to unzip it first.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Quote Originally Posted by Sparky View Post
    I have found it at a website and downloaded a *.zip file.

    I am using NetBeans - I have tried (within NetBeans) to go: tools - JAVA Platform - JAVADOC - add zip file.

    No luck with that attempt.

    I do see the file burried several directories down within the zip file.

    Thoughts?

    Thanks
    Sparky
    Unzip it.
    Under the build directory you'll find the jdom.jar. You want to add that to your build libraries. You'll also want to add the jars under the lib directory to your runtime libraries. They're the ones JDOM uses.

Similar Threads

  1. How do you import?
    By Gary20 in forum New To Java
    Replies: 2
    Last Post: 01-28-2011, 06:12 PM
  2. Import
    By gothrog in forum Java Applets
    Replies: 2
    Last Post: 05-13-2010, 11:16 PM
  3. import statement.
    By diRisig in forum New To Java
    Replies: 2
    Last Post: 02-08-2008, 12:34 AM
  4. Statement or Prepared Statement ?
    By paty in forum JDBC
    Replies: 3
    Last Post: 08-01-2007, 04:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •