Package scope and import statements

Hi everubody,
I'm studing a code: foo.java written by sb. else. In the code, I have:
package com.dir1.dir2.dir3;
import com.dir1.dir4.code1;
import com.dir1.dir5.code2;
The code: foo.java exists in the directory: com/dir1/dir2/dir3 as expected. However, in the import statements, there is NO dir4 and dir5 under com/dir1? Shouldn't the import statements be relative to the directory of package?
Guess I'm missing a point here... Any help is greatly apprecited.

When you import:
import co.mycompany.my.MyClass
then MyClass should reside in the directory:
co/mycompany/my, right?Right. Somewhere in the classpath there would have to be that directory structure. Again, that could be an actual directory name, or a path name in a Jar.
Then if the code: foo.java resides in the directory:
com/dir2/dir3 with the:
package com.dir1.dir2.dir3;
How the compiler and JVM finds the code MyClass
(which you imported in foo.java)?Thru the magic known as the classpath.

Similar Messages

  • Difference Betwen #include statement and Import statement

    What is the Difference between #include and Import statements!

    Why do you need to shout! Are you unware that English has a question mark that is used at the end of a question sentence! Java doesn't have #include! It only has import!
    Import in Java simply tells the compiler that when you say, for example, List, you mean, for example, java.util.List! It does not affect the generated class file in anyway!
    #include in C/C++ causes the body of the reference file to be inserted into the compilation stream! So, unlike Java's import, that file actually gets compiled into the final output!

  • Jsp declaration and import statement

    Hi All
    I have some problems with JSP.
    I have wrtten a declaration in jsp like this.....
    <%@ page language="java"%>
    <%!
    Date date = new Date();
    List al new ArrayList();
    public List getList(){
    al.add("Hi");
    return al;
    %>
    The List is-> <%= getList()%>
    Note that i did not import anything, it gives the output without any compile time/runtime error. How it is happening?
    If i write any thing in scriplets.......like List, Date, it is giving compile time error asking to import this.
    I am using weblogic8.1
    May i get the correct answer for this ASAP?
    Thanks and Regards
    Kasim
    [b]

    weblogic includes certain import statements in the JSP page when it is compiled.
    That is why u r not getting an error some times!!
    Check your weblogic documentation to find more details abt that
    But it is better to include the import statements , so the code will work in any server.

  • Conditional compilation and import statements

    I have a web application written in Flex and I'm trying  to build an AIR application from the same code base using conditional  compilation.
    In the AIR application, I need to have import statements  such as the following:
    import flash.data.SQLConnection;
    import  flash.filesystem.File;
    but I cannot have these import statements in the web  application because they are AIR only classes.
    I thought I could use conditional compilation to  overcome this issue but then I read the following on page http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7abd.html:
    "You cannot use constant Boolean values to conditionalize metadata or import statements."
    If that's the case, how can I have common codebase for Flex based web as well as desktop applications? Has anyone solved this conundrum?
    Thanks,
    Dilip

    DilipShah, as far as I see the classes are still included if referenced by import.
    Example:
    I have this statement in my class A
    if(CONFIG::platform == "ios") {
                        import B;
    I can see in linkreport that class B is still included and is included because A is referencing it.
    Flex harUI, classes are included into final swf file if any other class is referencing it through import even though not using it. I've experimented with it quiet a bit.

  • Export and import statements

    HI,
    I've developed a report which calls another standard report, which exports values to memory.
    i will import those values to my program. I am calling that standard program in b/g mode.
    I've used wait statement to make the program to wait for a while to update the exported values in the database cluster. This is working fine for small amount of data like 100 records like that.
    It's not working when data is more like more than 500 records. If i run the report in debugging mode i am getting output. But if i run directly (F8) the values are not exporting to memory and not getting the output. Not able to import data with F8, even i increase the wait time and used commit statment in the program.
    what wud be the problem and how can we rectify it?
    points assured for quick response.
    regards,
    Pra

    Hi Praneet,
    Consider the use of CALL FUNCTION <function> STARTING NEW TASK for your background process. Add
    PERFORMING subr ON END OF TASK.
    to continue processing.
    Put the export/import data into function interface.
    Regards,
    Clemens
    Message was edited by:
            Clemens Li

  • Export and import statement.

    what will be exported after the execution of follwoing 3 lines?
    It will be ship-to party or sold-to party?
    CUST1   =  tkomk-kunnr.
    CUSt2    =  TKOMK-KUNWE.
    export CUST1 to memory id cust2
    what is use of second statement in above lines?

    Hi,
    CUST1 = tkomk-kunnr.    --->  Contains Ship to party value
    CUSt2 = TKOMK-KUNWE.  --->  Contains Sold to party value
    Export CUST1 to memory id <b>cust2</>  -
    > Exporting the ship to party value to memory .   The bolded Cust2 is the name of the memory id it holds the value of cust1 i.e., Ship to party.
    So.. Ship to party value will be exported. and CUST1 contains Ship to party and CUST2 contains Sold to party value and CUST2of memory ID contains ship to party values.
    CUST2 of memory ID and CUST2 contains different values.
    Br,
    Laxmi

  • Import statement in .java files and .jsp files ..correction

    Guys I have few mysteries about this import statement.
    Please correct me if I am wrong.
    1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement in two.java I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
    BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import one.class in My.jsp .That is i have to say
    <%@page import="one"%>
    in My.jsp.
    and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder and MyJsp is compiled sucessfully.(Note that My.class is created in a folder different from c:\ClassFolder )
    But I am wondering why was there no need for me to import one.class in two.java.
    (Note I am using JDeveloper and Apache server)
    Please help.

    It has to do with packages. Most java classes are in a package, the name of which must conform to its place on the filesystem relative to the classpath. By that I mean that if you have com.mystuff.One.java, it must be in a folder com/mystuff where com is located somewhere in the classpath.
    What you've done is a little different. I'm assuming a couple of things:
    1. you have no package declaration at the top of one.java or two.java
    2. you have the current directory "." in your classpath.
    Java has the concept of the "default package", which covers classes without a declared package, and in your case is the current directory.
    So when you're in c:\sourcefolder and run the compiler, then "."="c:\sourcefolder", and that directory is part of the default package. No import statements are necessary for classes that are in the same package. This is why two.java can call methods in one.java without an import statement.
    When you run your jsp, the "current directory" part of your classpath is not c:\sourcefolder, but some other value (probably the directory you start your jsp engine from) You will have to import all non-java-library classes because the jsp itself becomes a java class, with a package that is determined by the jsp engine.

  • Import Statement without ID Specification

    There is an import statement
    IMPORT tab g_acc_tab FROM MEMORY.
    While UCChecking it.. it saying that
    import statement without id specification is only used for the sake of r/2 ......
    Can i Comment it ? If so won't my application  go into dump while running on 6.0cc???

    It has to do with packages. Most java classes are in a package, the name of which must conform to its place on the filesystem relative to the classpath. By that I mean that if you have com.mystuff.One.java, it must be in a folder com/mystuff where com is located somewhere in the classpath.
    What you've done is a little different. I'm assuming a couple of things:
    1. you have no package declaration at the top of one.java or two.java
    2. you have the current directory "." in your classpath.
    Java has the concept of the "default package", which covers classes without a declared package, and in your case is the current directory.
    So when you're in c:\sourcefolder and run the compiler, then "."="c:\sourcefolder", and that directory is part of the default package. No import statements are necessary for classes that are in the same package. This is why two.java can call methods in one.java without an import statement.
    When you run your jsp, the "current directory" part of your classpath is not c:\sourcefolder, but some other value (probably the directory you start your jsp engine from) You will have to import all non-java-library classes because the jsp itself becomes a java class, with a package that is determined by the jsp engine.

  • A problem from "import" statement

    When I was doing some test on "package" and "import" statement, I had a problem.
    1 I compiled one class:
    package com.sheng.population;
    public class A {
         public static int sum (int k, int l) {
              return (k+l);
    2 I tried to call the method 'sum' in A:
    import com.sheng.population.*;
    public class B {
         public static void main(String[] args){
              int i=9;
              int j=100;
              int k = A.sum(i, j);
              System.out.println(k);
    Then I got the error message:
    "B.java:7: cannot access A
    bad class file: E:\newjava\analysis\LDmeasure\A.java
    file does not contain class A"
    Only after I changed the import statement to "import com.sheng.population.A;" , then it worked.
    I just do not know why the '.*' does not work?
    Thanks

    Let's say your directory structure is "e:\newjava\com\sheng\population\A.class" and "e:\newjava\analysis\LDmeasure\A.java"
    If your Classpath is .;e:\newjava and when you compile, your current directory is e:\newjava\analysis\LDmeasure then you have A.java and A.class in your Classpath. When you use "import com.sheng.population.*;" the compiler does not know you mean com.sheng.population.A. The compiler finds A.java and thinks it is the A class that the B class needs. When it tries to compile A.java it finds the class name is com.sheng.population.A which causes the error. When you use "import com.sheng.population.A;" the compiler does not try to use A.java.
    If you are keeping the source code in a different directory from the compiled classes, then you should not have the source code in the Classpath. So, if you make sure the current directory is not e:\newjava\analysis\LDmeasure then it should compile.

  • Import statement .. what does it do ??

    Hi All,
    What is IMPORT statement doing ??
    IMPORT order_items_in to w_order_items_in from MEMORY ID
    'FREEGOODSTERMS'.
    can you kindly explain what this statement is doing ?
    I was by my friend that this is used to pass order_items from one session to this sesssion, but when I searched for FREEGOODSTERMS, I could find export after this statment. I was wondering how can import me first and then export.
    Please let me know.
    Thanks
    venkat.

    Hello Venkat,
    Sorry for late reply..
    Please see the program which other program submitting somewhere.
    if they are using multiple purpose then export and import statement may possible in one include.
    Best way just use where used list for that include and other programs searching like export and submit..
    For better understanding about export and import then see the below sample programs.
    Create one program and paste below code :
    REPORT  ZTEST_AMEM1.
    tables : lfa1.
    data : begin of i_lfa1 occurs 0 ,
           lifnr like lfa1-lifnr,
           name1 like lfa1-name1,
           land1 like lfa1-land1,
           end of i_lfa1.
    start-of-selection.
    select lifnr
           name1
           land1 from lfa1
           into table i_lfa1 up to 100 rows.
    Export
    export i_lfa1 to memory id 'SAP'.
    submit ztest_amem2 and return.
    write:/ 'hello'.
    Now create one more program  and paste below code :
    REPORT  ZTEST_AMEM2.
    data : begin of j_lfa1 occurs 0,
           lifnr like lfa1-lifnr,
           name1 like lfa1-name1,
           land1 like lfa1-land1,
           end of j_lfa1.
    start-of-selection.
    import i_lfa1 to j_lfa1 from memory id 'SAP'.
    loop at j_lfa1.
    write:/ j_lfa1-lifnr,j_lfa1-name1,j_lfa1-land1.
    endloop.
    Thanks
    Seshu

  • Additions required in portalapp.xml to import statements in JSPDynPage

    Hi all,
    What additions are required in portalapp.xml and import statements in JSPDynPage to include the equivalent of following JCO Clientservice in EP6 SP11?
    com.sap.portal.runtime.application.jcoclient.jcoclient
    The piece of code requiring the above is also given below.
    IJCOClientService clientService = (IJCOClientService) PortalRuntime.getRuntimeResources().getService("com.sap.portal.runtime.application.jcoclient.jcoclient");
    Thanking you ,
    Med venlig hilsen/Best regards
    Prabahar N.R

    Hi Prabahar,
    portalapp.xml: Add "com.sap.portal.runtime.application.jcoclient" to the SharingsReferences.
    import: com.sapportals.portal.prt.service.jco.IJCOClientService
    Hope it helps
    Detlev

  • Import statement and directory structure

    First of all, sorry for such a long post, I believe part of it is because I am unsure of the concept of importing in Java. Secondly, Thanks to anyone who can ultimately enlighten me to the concept of import. I did ask this question before in the "erorr and error handling" forum, and the people who have helped me there did a great job. But, I believe I require a little more clarification and thus have decided to post here.
    Anyhow, my question..
    Could someone explain to me the concept of the import statement, or direct me to a webpage with sort of explanation for newbies? For some reason, I am having a hard time grasping the concept.
    As I understand it, the import statement in Java, is very similar to the namespace keyword in C. That is to say, import doesn't actually "import" any source code, the way that the #include statement does in C.
    So I suppose what my question is, say I have a java class file like below:
    //filename: sentence.java
    //located: c:\school\csc365
    package csc365;
    class sentence
    //some variables here..
    //some constructor here..
    //some methods here..
    And some sample program like the one below which implements the above..
    //filename: test.java
    //located: c:\school\csc365
    import csc365.*;
    import java.io.*;
    class test.java
    //creates some sentence object
    //uses the object's methods
    //some other things.
    As I understand it, the test.java file should not compile because the csc365 package is not in the correct directory. (assuming of course, the classpath is like c:\school\csc365;c:\school )
    But, ... where then should the sentence.java be located? In a subdirectory of c:\school called csc365 (i.e c:\school\csc365\) ?
    And thus that would mean the test.java file could be located anywhere on the hard drive?
    I suppose, I just need a little clarification on the correlation between a package's "name" (i.e package csc365; ) and its corresponding directory's name, and also how the javac compiler searches the classpath for java classes.
    ..So, theoretically if I were to set the classpath to look in every conceivable directory(provided the directory names were all unique) of the harddrive, then I could compile a test.java anywhere?
    As a note: I have been able to get the test.java file to compile, by leaving out the import statement in the test.java file, and also leaving out the package statement for the sentence class, but I assume this is because the files are defaulted to the same package?

    Hi Mary,
    No, import isn't analogous to C++ namespace - Java package is closer to the namespace mark.
    import is just a convenience for the programmer. You can go your whole Java career without ever writing an import statement if you wish. All that means is that you'll have to type out the fully-resolved class name every time you want to use a class that's in a package other than java.lang. Example:
    // NOTE: No import statements
    public class Family
       // NOTE: fully-resolved class names
       private java.util.List children = new java.util.ArrayList();
    }If you use the import statement, you can save yourself from typing:
    import java.util.ArrayList;
    import java.util.List;
    public class Family
       // NOTE: fully-resolved class names
       private List children = new ArrayList();
    }import isn't the same as class loader. It does not bring in any source code at all.
    import comes into play when you're compiling or running your code. Java will check to make sure that any "shorthand" class names you give it live in one of the packages you've imported. If it can't find a matching fully-resolved class name, it'll give you a message like "Symbol not found" or something like that.
    I arrange Java source in a directory structure that matches the package structure in the .class files.
    If I've got a Java source file like this:
    package foo.bar;
    public class Baz
       public static void main(String [] args)
            Baz baz = new Baz();
            System.out.println(baz);
       public String toString()
           return "I am a Baz";
    }I'll store it in a directory structure like this:
    root
    +---classes
    +---src
          +---foo
               +---bar
                    +---Baz.javaWhen I compile, I go to root and compile by typing this:
    javac -d classes foo/bar/*.javaI can run the code from root by typing:
    java -classpath classes foo.bar.BazI hope this wasn't patronizing or beneath you. I don't mean to be insulting. - MOD

  • Import statement in .java files and .jsp files

    Guys I have few mysteries about this import statement.
    Please correct me if I am wrong.
    1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
    BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import the class I want to use.That is i have to say
    <%@page import="one"%>
    and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder.(Note that My.class is created in a folder different from c:\ClassFolder )
    But I am wondering why was there no need for me to import one.class in two.java.
    (Note I am using JDeveloper and Apache server)
    Please help.
    In this case the pSo I am wondering in JSP why it doesn't take the class I am looking for from the classpath .
    Help.

    You have to understand Java scoping rules. In the 1st scenario with the two Java files I am guessing neither one of them begins with a package statement. This means that they belong to the default package. When you compile the compiler uses the classpath to resolve method calls looking in the default package since there was no import statement specified in two.java. JSP is a little different. Now I just read this here in these forums a couple of days ago. Since the classfiles generated from the JSP files are not in the CLASSPATH they are loaded by a different classloader. This is why you have to import all references to all classes in the default package.

  • Import statement reports 'package does not exist'

    I am seeing another odd error. I'm working on learning how to read and write to text files, and I have 2 errors reported, but one is obviously caused by the other. My package is labeled as such (copy>paste of package line):
    package michaelchristopherp4db;
    and the import line is this (copy>paste again):
    import michaelchristopherp4db.ProductRecord;
    However, Netbeans looks at the import and flags it red, saying package michaelchristopherp4db does not exist. this caused my line:
    ProductRecord product = new ProductRecord();
    to also be flagged in red as it cannot find the ProductRecord class. However, it has no problems with any of the product.get* method calls. Thank you in advance for any ideas or input.
    here is the full code of the file reporting the errors.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package michaelchristopherp4db2;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.lang.IllegalStateException;
    import java.lang.SecurityException;
    import java.util.NoSuchElementException;
    import java.util.Formatter;
    import java.util.FormatterClosedException;
    import java.util.Scanner;
    import michaelchristopherp4db.ProductRecord;
    /*  @author info
    public class readTxt
        private Scanner txtfile;
        private Formatter wishList;
        private Formatter giftIdeas;
        private Formatter priceError;
        //let user open file
        public void openFile()
        {//open method openFile
            try
            {//open try block
                priceError = new Formatter("priceerror.txt");//open object for items with invalid prices
                giftIdeas = new Formatter("giftideas.txt");//open object for gift ideas
                wishList = new Formatter("wishlist.txt");//open object for wish list
                txtfile = new Scanner(new File("products.txt"));//tell the compiler which file to use for input
            }//close try block
            catch (FileNotFoundException fileNotFoundException)
            {//open file not found catch block
                System.err.println("Error opening or creating file.");
                System.exit(1);
            }//close file not found catch block
            catch ( SecurityException securityException )
            {//start catch for SecurityException
                System.err.println("File Write access is denied.");
                System.exit(1);//END PROGRAM
            }//end catch
        }//close openFile method
        public void readProducts()
        {//open readProducts method
            ProductRecord product = new ProductRecord();//create object to hold read data
            //print headers for for output columns
            System.out.printf("%-10s%-12s%10s\n", "Product ID", "Product Name", "Price");
            try //read records from the file
            {//open try block
                while (txtfile.hasNext())
                {//open while
                    product.setproductID(txtfile.nextInt());//get productID
                    product.setproductName(txtfile.next());//get product name
                    product.setproductPrice(txtfile.nextDouble());//get product price
                    //print collected product details
                    System.out.printf("%-10d%-12s%10.2f\n", product.getproductID(),
                            product.getproductName(), product.getproductPrice());
                    if (product.getproductPrice()>50.0)
                    {//open if to store items $50 or more to wishlist.txt
                        wishList.format("%-10d%-12s%10.2f\n", product.getproductID(),
                                product.getproductName(), product.getproductPrice());
                    }//close if $50 or greater
                    else if (product.getproductPrice()<0.0)
                    {//open if less than zero
                        priceError.format("%-10d%-12s%10.2f\n", product.getproductID(),
                                product.getproductName(), product.getproductPrice());
                    }//close if less than zero
                    else
                    {//open else for gift ideas from $0 to $50
                        giftIdeas.format("%-10d%-12s%10.2f\n", product.getproductID(),
                                product.getproductName(), product.getproductPrice());
                    }//close else for gift ideas
                }//close while
            }//close try block
            catch (NoSuchElementException elementException)
            {//open no such element exception catch
                System.err.println("File improperly formed.");
                txtfile.close();//close text file
                System.exit(1);
            }//close no such element exception catch
            catch (IllegalStateException stateException)
            {//open illegal state exception catch
                System.err.println("Error reading from file.");
                System.exit(1);
            }//close illegal state exception catch
        }//close readProducts method
        //close file and end application
        public void closeFile()
        {//open closeFile method
            if (txtfile != null)
                txtfile.close();//close file
        }//close closeFile method
    }//end application readTxtAnd the code at the top of the class I am trying to import (so you can see the package I am trying to import)
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package michaelchristopherp4db;
    *  @author
    public class ProductRecord {

    I am embarrassed to admit this, but I am completely lost on the last question.. I have no clue wether it is a convenience for development or a dependancy, as I have not learned those terms or distinctions yet. For now I copied the ProductRecord file into my new project folder and renamed it's project line to match the new project name. However, while that eliminated the package does not exist error, and netbeans reports no errors now, when I run the program it does not write the new files. I have made some modifications to the code tryiing to get it to write properly but so far no luck in makingit work. Here is the current version of the file not running right.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package michaelchristopherp4db2;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.lang.IllegalStateException;
    import java.lang.SecurityException;
    import java.util.NoSuchElementException;
    import java.util.Formatter;
    import java.util.FormatterClosedException;
    import java.util.Scanner;
    /*  @author
    *   Michael Christopher
    *   IT215-1004D-03
    *   December 30, 2010
    *   Phase 4 DB 2
    public class readTxt
        private Scanner txtfile;
        private Formatter wishList;
        private Formatter giftIdeas;
        private Formatter priceError;
        //let user open file
        public void openFile()
        {//open method openFile
            try
            {//open try block
                priceError = new Formatter("priceerror.txt");//open object for items with invalid prices
                giftIdeas = new Formatter("giftideas.txt");//open object for gift ideas
                wishList = new Formatter("wishlist.txt");//open object for wish list
                txtfile = new Scanner(new File("products.txt"));//tell the compiler which file to use for input
            }//close try block
            catch (FileNotFoundException fileNotFoundException)
            {//open file not found catch block
                System.err.println("Error opening or creating file.");
                System.exit(1);
            }//close file not found catch block
            catch ( SecurityException securityException )
            {//start catch for SecurityException
                System.err.println("File Write access is denied.");
                System.exit(1);//END PROGRAM
            }//end catch
        }//close openFile method
        public void readProducts()
        {//open readProducts method
            ProductRecord product = new ProductRecord();//create object to hold read data
            //print headers for for output columns
            wishList.format("%-10s%-12s%10s\n", "Product ID", "Product Name", "Price");
            giftIdeas.format("%-10s%-12s%10s\n", "Product ID", "Product Name", "Price");
            priceError.format("%-10s%-12s%10s\n", "Product ID", "Product Name", "Price");
            try //read records from the file
            {//open try block
                while (txtfile.hasNext())
                {//open while
                    product.setproductID(txtfile.nextInt());//get productID
                    product.setproductName(txtfile.next());//get product name
                    product.setproductPrice(txtfile.nextDouble());//get product price
                    if (product.getproductPrice()>50.0)
                    {//open if to store items $50 or more to wishlist.txt
                        wishList.format("%-10d%-12s%10.2f\n", product.getproductID(),
                                product.getproductName(), product.getproductPrice());
                    }//close if $50 or greater
                    else if (product.getproductPrice()<0.0)
                    {//open if less than zero
                        priceError.format("%-10d%-12s%10.2f\n", product.getproductID(),
                                product.getproductName(), product.getproductPrice());
                    }//close if less than zero
                    else
                    {//open else for gift ideas from $0 to $50
                        giftIdeas.format("%-10d%-12s%10.2f\n", product.getproductID(),
                                product.getproductName(), product.getproductPrice());
                    }//close else for gift ideas
                }//close while
            }//close try block
            catch (NoSuchElementException elementException)
            {//open no such element exception catch
                System.err.println("File improperly formed.");
                txtfile.close();//close text file
                System.exit(1);
            }//close no such element exception catch
            catch (IllegalStateException stateException)
            {//open illegal state exception catch
                System.err.println("Error reading from file.");
                System.exit(1);
            }//close illegal state exception catch
        }//close readProducts method
        //close file and end application
        public void closeFile()
        {//open closeFile method
            if (txtfile != null)
                txtfile.close();//close file
        }//close closeFile method
    }//end application readTxtwith the System.out.printf lines in the ReadProducts method it would properly print to screen all of the elements in the products.txt file, it is not outputting to the other .txt files at all. I will be exploring the closeFile method in case the error is due to not closing all of the files in that method, but does anyone else see what might cause it not to output the data to the appropriate .txt files?

  • Package-Import statement problem

    Greetings JDC Community...
    This problem has been driving me insane for over an hour. It's a simple package-import problem. I have a file called DataAddingTest.java which is in my C:\Java\risk\tests\ directory and it has a package statement "package risk.tests;". Then I try to import all of the files I have in the risk directory by using "import risk.*;" and it whines in error that "package risk does not exist". I'm about ready to throw my computer... can someone help me? Thanks for your time.
    -Billy Mahabir

    Hello again everyone...
    It seems all of you have mistaken my problem to some degree. The beginning part of my DataAddingTest.java file reads like this:
    // This class tests adding data to the data structures in my Risk(c) game.
    package risk.tests;
    import risk.*;
    DataAddingTest.java is in my C:\Java\risk\tests\ directory. I am trying to import a whole bunch of files from my main risk directory, i.e., C:\Java\risk\. And it is just not working. I have no idea why. I'm pretty sure I have the correct syntax for what I'm doing; it should work. The exact error message I get at compile-time is this:
    DataAddingTest.java:5: package risk does not exist
    import risk.*;
    ^
    There is indeed a C:\Java\risk\ directory (of course), and it contains many java files, all of which have "package risk;" declared at the top. And yes, I have also compiled those before I try to compile this file. Someone please help! Thanks for everyone's time.
    -Billy Mahabir

Maybe you are looking for

  • Conversion of XML file from ANSI to UTF-8 encoding in SAP 4.6C

    Hi All,   Im working on SAP 4.6C version.I have generated a XML file from my custom report.It is downloading in ANSI format.But i need to download this into UTF-8 format.So can anyone please let me know how to do this? Is this possible in 4.6C versio

  • Dynamic flat file name as source

    Hi All, I working on ODI 11g 11.1.1.3 version. I have Flat file say ABC01 as source, flat file was successfully load into target. But next day new file say ABC02 with same structure was generate from client. Every day new file is generate say ABC03,

  • PDFs are not opening on iphone

    PDFs are opening on my ipod but not on iphone- I've just upgraded to OS6. Is this the problem?

  • Exclude expired accounts in user profile synchronization

    Hi  I would like to exclude the expired accounts from the AD import in SharePoint 2013 user profile sync. I managed to exclude disabled accounts using userAccountControl bit equals on 2. Could you please suggest on how the exclusion filter can be use

  • HT6446 My Health Data is showing my total steps for Daily average....

    specs: Using Apple Health App, with the Withings Health Mate and My Fitness Pal as the only 2 sources. Using an iPhone 5s with  26.7 GB capacity 4.2 GB available Model Number NE299LL/A OS Version 8.1 (12B411) I Updated all my Apps. I have gone into t