Program Problems...Import Statement needed?

I am currently a student at DeVry University, and today I had my java class where my professor played a video on java programming for us made by a group called "CBTNuggets". The video went over Inner classes and the professor had us copy the code as the person in the video was typing it up. While attempting to compile the code I encountered several compiler errors on the second of the two files I had typed, I am going to first post the source code for both files, and then follow that with the compiler errors that were generated when I attempted to compile the code. If anyone is able to assist me with this I would greatly appreciate it, I think I may need to add an import statement ;however, I do not know how to implement one for user defined Inner Classes:
Invoice.java was the file that contained the Inner classes
* Invoice.java
* Created on February 1, 2007, 1:39 PM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
* @author vontux
import java.util.*;
public class Invoice {
    private String strCustName;
    private String strCustAddr;
    private int intInvoiceNum;
    private Date dtInvoiceDate;
    /** Creates a new instance of Invoice */
   Invoice(String sCN, String sCA, int iN, Date dt)
       strCustName = sCN;
       strCustAddr = sCA;
       intInvoiceNum = iN;
       dtInvoiceDate = dt;
  class InvoiceItem //enclosed class
      private int intLineItem;
      private int intItemID;
      private int intUnits;
      private String strItemDesc;
      InvoiceItem(int li, int id,String desc, int iu)
          intLineItem = li;
          intItemID = id;
          intUnits = iu;
          strItemDesc = desc;
      public void showInvoice()
          System.out.println("Customer Name: " + Invoice.this.strCustName);
          System.out.println("Item Description: " + strItemDesc);
}UseInvoice.java is the class that is supposed to create objects of the Inner classes from Invoice.java and then run the code:
* UseInvoice.java
* Created on February 1, 2007, 1:51 PM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
* @author vontux
import java.util.*;
public class UseInvoice {
    public static void main(String[] args)
        Date today = new Date();
        Invoice myInvoice = new Invoice("Robert Barrr", "12345 N. CBTNuggets Dr.", 321,today );
        Invoice.InvoiceItem myInvItem = myInvoice.new InvoiceItem(1, 345,"Toy Train", 2);
        myInvItem.showInvoice();
    /** Creates a new instance of UseInvoice */
    public UseInvoice() {
}And here are the compiler errors that I recieved:
C:\Documents and Settings\Matt\Desktop\temptemp\temp\UseInvoice.java:19: cannot
find symbol
symbol  : class Invoice
location: class UseInvoice
        Invoice myInvoice = new Invoice("Robert Barrr", "12345 N. CBTNuggets Dr.
", 321,today );
        ^
C:\Documents and Settings\Matt\Desktop\temptemp\temp\UseInvoice.java:19: cannot
find symbol
symbol  : class Invoice
location: class UseInvoice
        Invoice myInvoice = new Invoice("Robert Barrr", "12345 N. CBTNuggets Dr.
", 321,today );
                                ^
C:\Documents and Settings\Matt\Desktop\temptemp\temp\UseInvoice.java:20: package
Invoice does not exist
        Invoice.InvoiceItem myInvItem = myInvoice.new InvoiceItem(1, 345,"Toy Tr
ain", 2);
               ^
3 errors

There are no errors occurs when I compile this two java files .
Here are the result I'm using jdk1.6 and dos command
[output]
[search path for source files: [D:\J2SDK1.6.0\lib, .\out]]
[search path for class files: [D:\J2SDK1.6.0\jre\lib\resources.jar, D:\J2SDK1.6.0\jre\lib\rt.jar, D:\J2SDK1.6.0\jre\lib\sunrsasign.jar, D:\J2SDK1.6.0\jre\lib\jsse.jar, D:\J2SDK1.6.0\jre\lib\jce.jar, D:\J2SDK1.6.0\jre\lib\charsets.jar, D:\J2SDK1.6.0\jre\classes, D:\J2SDK1.6.0\jre\lib\ext\dnsns.jar, D:\J2SDK1.6.0\jre\lib\ext\localedata.jar, D:\J2SDK1.6.0\jre\lib\ext\sunjce_provider.jar, D:\J2SDK1.6.0\jre\lib\ext\sunmscapi.jar, D:\J2SDK1.6.0\jre\lib\ext\sunpkcs11.jar, D:\J2SDK1.6.0\lib, .\out]]
[parsing started .\Invoice.java]
[parsing completed 31ms]
[parsing started .\UseInvoice.java]
[parsing completed 15ms]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/String.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/util/Date.class)]
[checking Invoice]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/System.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/io/PrintStream.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/io/FilterOutputStream.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/io/OutputStream.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/io/Serializable.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/StringBuilder.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/AbstractStringBuilder.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/CharSequence.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/Comparable.class)]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/StringBuffer.class)]
[wrote .\out\Invoice$InvoiceItem.class]
[wrote .\out\Invoice.class]
[checking UseInvoice]
[loading D:\J2SDK1.6.0\lib\ct.sym(META-INF/sym/rt.jar/java/lang/Class.class)]
[wrote .\out\UseInvoice.class]
[total 734ms]
[output]
check your syntax to compile these two files, may be you can show your syntax to compile these two files
javac [options] [classpath] source

Similar Messages

  • Not a programming problem! but need help

    last week my teacher taught us some addition and subtraction of binary, decimal, hex and octal number. and it's quite easy. but the last topic for me seems to be hard. MULTIPLY AND DIVISION of number system.
    can anybody point me out to some text or link in the web pertaining to this subject
    please!!

    Here is one page: http://www.cut-the-knot.com/blue/SysTable.shtml
    The idea is basically the same as in base 10 (you do know long multiplication and division?), only need to use the multiplication and addition tables of the correct base...

  • JSP import statement problem

    Hey, I got confused with all import statement with jsp.
    Here is my problem.
    Folder structure:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\webapps\ROOT\WEB\S\A
    This folder contains a.jsp.
    JSP code:
    <%@ page
         language="java"
         import="java.sql.*, MyPackage.DataBase"
         errorPage=". . ."
         contentType="text/html; charset=windows-1251"
    %>
    <%
           Connection connection = null;
         Statement statement = null;
           DataBase dataBase = new DataBase( connection, statement );
    %>
    ...Error message that I get:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a_jsp.java:7: package MyPackage does not exist
    import MyPackage.DataBase;
                       ^
    An error occurred at line: 104 in the jsp file: /WEB/S/A/a.jsp
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a100_jsp.java:147: cannot resolve symbol
    symbol  : class DataBase
    location: class org.apache.jsp.WEB.S.A.a_jsp
           DataBase dataBase = new DataBase( connection, statement );
            ^
    ...How do I import that class so I can use it?
    Do I need to use useBean?
    What do I need to do?
    Thanks

    DataBase class does not extend java.sql.
    I put this into my jsp page
         import="java.sql.*;"
         import="MyPackage.DataBase;" Here is the error message
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a_jsp.java:7: 'class' or 'interface' expected
    import MyPackage.DataBase;;
    ^
    1 error
    ...

  • Java programming(import statement)

    My query is that what if i import whole package instead of one class being used in my code.
    eg.
    if i need " java.awt.Button" in my program code
    and my import statement is
    import java.awt.*;
    will it be reduce execution performance of my program?
    or it will reduce only Complie time performance?

    Only the compile time performance. All the import statement does is tells the compiler it can use the classes. Try importing a whole swathe of classes into a small program and see what I mean. The resulting class file doesn't bloat.

  • 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.

  • Java import statement problems

    Hello...
    I have the book "Java in a Nutshell, 2nd ed" and have a query about a nested top-level interface example they have in the book.
    Basically there's two files/classes. The first, LinkedList.java, is as follows:
    public class LinkedList {
        public static interface Linkable {
            // Linkable interface details here
        // rest of LinkedList class here
    Next is LinkedList.java as follows:
    import LinkedList.*;
    class LinkableInteger2 implements Linkable {
        // rest of LinkableInteger2 class here
    Now I thought the import statement had two forms - and both used a package name as part of the statement:
    import package.class;
    import package.*;
    Obviously, neither class has a package statement.
    As written, these classes do not compile. Am I right in assuming the lack of a package name is causing this problem, or is there something else going on here?
    Thanks...
    Mark.

    Since you don't have package statements in the files, the classes are being placed in the default package. You cannot explicitly import classes from the default package. Al classes in the default package, the java.lang package and the current package are always imported automatically. Your import statement is incorrect - remove it.

  • Problems with IMPORT STATEMENT

    Please, can someone assist me? I am using Java Studio Enterprise 8.1 & Netbeans to design a java application and input form. But the wizard keeps on generating repeated class and subclasses even after I have used the import statement. Its making my program looks clumsy.
    I just want to use import statement once and start using the variable in the program without repeating the declaration.
    For instance, after importing javax.swing.*, I just want to be able to specify in my program (e.g JPanel Coylogo) without the wizard generating another private javax.swing.JPanel Coylogo.
    How can I do it. Please help. I will appreciate
    You look at the following section of the program to unstand what I mean. Thank you.
    import java.awt.HeadlessException;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.*;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import javax.swing.*;
    import java.sql.Date;
    * @author */
    public class inputForm extends JFrame
    private Connection con;
    private Statement stmt;
    private int k;
    ResultSet rs=null;
    // Variables declaration - do not modify
    private javax.swing.JLabel ClassLabel;
    private javax.swing.JPanel Connectivitypanel;
    private javax.swing.JPanel Coylogo;
    private javax.swing.JCheckBox DataCapable;
    private javax.swing.JLabel DateLabel;
    // End of variables declaration
    * Creates new form inputForm
    public inputForm()
    //con = new dbConnect();
    initComponents();
    con = dbconnection();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents()
    Coylogo = new javax.swing.JPanel();
    PhoneType = new javax.swing.JPanel();
    PhoneIdLabel = new javax.swing.JLabel();
    ClassLabel = new javax.swing.JLabel();
    phoneid = new javax.swing.JTextField();
    DateLabel = new javax.swing.JLabel();
    Connectivitypanel.setBorder(javax.swing.BorderFactory.createTitledBorder("CONNECTIVITY"));
    pbluetooth.setText("Bluetooth");
    pbluetooth.setActionCommand("bluetooth");
    pbluetooth.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    pbluetooth.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    pbluetooth.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    pbluetooth.setMargin(new java.awt.Insets(0, 0, 0, 0));
    }// </editor-fold>
    private void allPhonesTypeActionPerformed(java.awt.event.ActionEvent evt)
    }

    disable add imports or organize imports in your IDE

  • Firefox have some promlems and it block when is opeining hotmail, in my laptop always have that problem, so i need check my email using another programs...that problem is in my laptop or it´s a problem of navigator??

    Firefox have some problems and it block when is opening hotmail, in my laptop always have that problem, so i need check my email using another programs...that problem is in my laptop or it´s a problem of navigator??

    I know you can't help with my Yahoo problem, however, apparently at some time in the past I have went to the Sync and tried to figure it out on both my laptop and my desktop, because I have the long snyc key information. However, when I go to try to sync both computers I never get the box to enter that key on either one. That is my problem. So should I try and get a new sync key and see if that works.

  • Weird import statement problem

    Hi
    I have a strange problem with an application I just developed. Once compiled, if I try to run it on another machine other than the one I developed on, I get a NoClassDefFoundError relating to a class that I did not use. I look at the class file (in a decompiled state) and there is an import statement in there that is not in the source file!! Can anyone tell me why this might have happened?
    the import is a symantec class/package I have never used to my knowledge at all and yet it shows up in the binary class file after compilation.
    Thanks for any suggestions.

    I did use Visual Cafe during parts of the development but I have never imported anything like what is in the class file. I assumed it was VC that was doing it but wasn't sure.
    Thanks.

  • Java import statement memory problem

    Hi,
    will java.io.* loads all the classes in io package to the memory? will it afftect the program performance?

    RajBabu wrote:
    I hope that import statement might present in a java class fileNo, import statements are in no way represented in the java class files. All references to external classes are made via their fully quallified class names in a class file (com.foo.Bar and not just Bar*).
    Imports only serve as a shortcut so that you don't have to write the full class name everywhere in your Source code. You could just as well write a program without using any import statements, just by using the fully qualified class names of each class you use and it would produce the same class files (although the source code would be rather unreadable).
    * actually the format is different, but the idea is the same

  • Why the need of "import" statements for Java base code?

    If for documentation purposes, a compiler option to produce an "import list" would have been sufficient.

    import statements act as really simple namespaces.
    Instead of the programer having to specify:
    java.io.File f = new java.io.File("c:\\");
    the code can have a 'namespace' added to do the following:
    import java.io.file;
    File f = new File("c:\\);
    it's a way of getting around similiarly named classes, but still have the ability to drop the 'java.io.' part.

  • Have AE7; Problem importing prproj file into pc; get placeholder instead. What do I need to do to open up the video files here. They are .mov in quicktime.

    Have AE7; Problem importing prproj file into pc; get placeholder instead. What do I need to do to open up the video files here. They are .mov in quicktime.

    Please be more specific. What Premiere project? What version of Premiere? Which operating system? What CoDecs do the QT fiels use? Are all the video files in the correct folders inside the Premiere project structure? Your description sounds like you are attempting to open a Mac based project on a PC and your video files are either in the wrong location or use a Mac-specific CoDec, hence they cannot be read on a PC.
    Mylenium

  • I am thinking of buying a iPad but my main desktop machine uses Windows 7 and MS Office.  How easy or difficult is it to transfer data files between the iPad and Windows?  Are there obvious problems or the need for some form of conversion programs?

    I am thinking of buying a iPad but my main desktop machine uses Windows 7 and MS Office.  How easy or difficult is it to transfer data files between the iPad and Windows?  Are there obvious problems or the need for some form of conversion programs?
    Many thanks for any advice.
    David

    You don't need conversion programs, iTunes can copy most of your content over to the iPad via the file sharing section, and some apps also support Dropbox, email attachments, transfer via your wifi network. There are a number of apps that you can get that support Microsoft office file (microsoft don't make an app versions of their software) e.g. from Apple there are Pages (word support), Numbers (excel) and Keynote (powerpoint), and from third-parties there are apps such as Documents To Go and QuickOffice HD

  • Trying to download Itunes 11.1 and it states need Apple support program??

    Unable to download Itunes to my PC. I have the new IPAD AIR and need 11.1. ?? Do I need to download a flash player maybe? Error message states "need Apple support program"

    Let's try a standalone Apple Application Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of the issue.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/
    Right-click the iTunesSetup.exe (or iTunes64Setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleApplicationSupport.msi to do a standalone AAS install.
    Does it install properly for you?
    If instead you get an error message during the install, let us know what it says. (Precise text, please.)

  • I Baught A iMac 2010 From Someone it came with lion but for the programs i use i need snow leopard but when trying to install it won't boot from usb or cd what can be the problem i've been at this for over 24 hours if anyone ca help it'd be greatly apprec

    I Baught A iMac 2010 From Someone it came with lion but for the programs i use i need snow leopard but when trying to install it won't boot from usb or cd what can be the problem i've been at this for over 24 hours if anyone ca help it'd be greatly appreciate it! Thanks!

    Downgrade OS X Lion To Snow Leopard [Video How-To]
    http://www.cultofmac.com/110614/downgrade-os-x-lion-to-snow-leopard-video-how-to /
    How To Downgrade OS X Lion To Snow Leopard: The Complete Tutorial
    http://www.redmondpie.com/how-to-downgrade-os-x-lion-to-snow-leopard-the-complet e-tutorial/
    How To Downgrade from Apple OS X Lion to Snow Leopard
    http://www.pcmag.com/article2/0,2817,2389334,00.asp

Maybe you are looking for

  • S_ALR_87012083 Report Issue

    S_ALR_87012083 - List of Vendor Line Items, not displaying correct values for total. Consider for one vendor there are 3 forgien currency totals i.e. EUR / GBP / USD. While converting this total in local currency it summing all values (EUR + GBP + US

  • Suggestion for a good button theme

    Hey, Looking for a suggestion for a good button. I do not have access to Photoshop and all I am using is the ones that can with Studio Pro. It is just a plan white square. This is a Christian family movie so something more to the point of the theme m

  • What is the difference in SAP CRM and SAP R/3

    Hi Experts, I am new to the CRMs system. Please clarify the following points. what is the difference between SAP CRM system and SAP R/3? In SAP R/3 contains the different module like SD , FI, MM, HR... Like that in SAP CRM also have different modules

  • Accessing the clipboard in an Applet?

    Hello. I'm currently trying to allow copy & paste in an applet (extends JApplet). I'd like it to be able to paste in text from other sources (Notepad, websites, etc.) when the user right-clicks the mouse, and for this, it seems I need to use the syst

  • Viewing Photo Stream on Mac

    Can I view the photos within my photo stream on my MacBook Air? Or does iCloud only serve as a medium for saving the photos?