Results 1 to 3 of 3
  1. #1
    ilans11il is offline Member
    Join Date
    May 2013
    Rep Power

    Default Import java files

    Hi ,
    I'm doing my first steps in java so please be gentle ...
    enclosed a part of a java program .

    Q -1 - From where those files are imported ? ( what is their path ? )
    Q -2 - Does those files are related to the java version that I have on my PC ?

    Java Code:
    package SensorMonitor;
    import java.util.*;
    import javax.imageio.*;
    import java.awt.*;

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    The Netherlands
    Rep Power

    Default Re: Import java files

    A1: A package is a bunch of java/class files grouped together. Think files and directories. It so happens that packagenames are actual directories! So your example Java file should be contained in a directory called SensorMonitor. (Note: name conventions dictate that packages should be written lowercase). When you put this directory structure inside a jar file you have a library. If you add these libraries to the classpath of your program the import statement will find them automatically.
    A2: Yes. Obviously libraries can change, so the contents of each JDK/JRE may vary.

    @see Creating and Using Packages (The Java™ Tutorials > Learning the Java Language > Packages)

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Import java files

    Note that the Java import statement is totally different from the C/C++ include prepocessor directive; the first statement imports compiled Java classes (i.e. it invokes a ClassLoader for the class), while the preprocessor directive imports source code in another source code compilation unit. The Java compiler uses introspection (see the Class class) in order to obtain its information about the class. If no class existed yet or is outdated, the compiler recursively invokes itself and compiles the other source code (if it can be found).

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. how to import downloaded .gif files into the software.
    By elecleoalune in forum New To Java
    Replies: 9
    Last Post: 04-12-2011, 02:27 PM
  2. Import my own class files into eclipse
    By teaicky in forum New To Java
    Replies: 3
    Last Post: 02-07-2011, 09:45 PM
  3. import from dsv files and export to csv files
    By 10x2 in forum New To Java
    Replies: 12
    Last Post: 04-30-2010, 11:56 AM
  4. Import files from NetBeans
    By Juuno in forum Eclipse
    Replies: 2
    Last Post: 04-08-2009, 05:20 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