Results 1 to 3 of 3

Thread: Import

  1. #1
    gothrog is offline Member
    Join Date
    May 2010
    Rep Power

    Default Import


    I'm having an issue trying to get my import to work. I'm a novice as a java developer.

    The files are in the same directory, but if I type in this it doesn't work.
    import myPackage.myClass;

    It says it can't find the myPackage. Can someone help?
    I'm not sure how to get it to know where the myPackage is.



  2. #2
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Rep Power


    I am not sure what is applet thread here about :confused:

    But anyway...

    Any package import means that package is on your main class level or lower.
    Just create package (folder) next to your main source file and add a *.java file to it...
    If you use an IDE you should read its documentation to find out how to create a new package in the frames of your project.
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    The import statement is a way to add paths for the compiler to find class definitions.
    If the referenced classes are in the same directory as the source, then you shouldn't need an import statement. Unless the classes are in packages, in which case the class files will have to be in folder/paths that match the package name.
    Could you give an example? Eg the filename, packages, classes referenced

Similar Threads

  1. Import your own package
    By Umi in forum New To Java
    Replies: 4
    Last Post: 02-15-2010, 09:05 AM
  2. Can not import jxl.*
    By AnnieDing in forum Java Servlet
    Replies: 3
    Last Post: 01-22-2010, 03:52 PM
  3. Cant import RowSorter?
    By ProgrammingPup in forum New To Java
    Replies: 3
    Last Post: 11-17-2009, 09:52 PM
  4. import problem
    By anki.gulsvart in forum Networking
    Replies: 9
    Last Post: 10-16-2009, 07:03 PM
  5. Import not working
    By ribbs2521 in forum New To Java
    Replies: 5
    Last Post: 12-16-2008, 06:14 AM

Posting Permissions

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