Cannot find symbol for some jms methods

Hi, I'm new to JMS and am having trouble compiling the HelloWorld example. I am able to create a connection but for some reason I cannot create a session from the same connection. I am however able to call some of the other methods such as getClientID, start, and close. Below is a copy of what i have compiled so far (which is basically a copy of the example code), the error message I get, and what I have CLASSPATH set to. If my CLASSPATH is not set correctly, I would assume none of the code would compile which is very confusing. Any help is appreciated, thanks!
//Step 1:
//Import the JMS API classes.
import javax.jms.ConnectionFactory;
import javax.jms.Connection;
import javax.jms.Session;
import javax.jms.MessageProducer;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Message;
import javax.jms.TextMessage;
import javax.jms.*;
//Import the classes to use JNDI.
import javax.naming.*;
import java.util.*;
public class HelloWorldMessage
public static void main(String[] args){
     System.out.println("Hello World!");
     try{
Queue myQueue;
     // Instantiate a Oracle GlassFish(tm) Server Message Queue ConnectionFactory administered object
     com.sun.messaging.ConnectionFactory myConnFactory = new com.sun.messaging.ConnectionFactory();
     // Create a connection to the Oracle GlassFish(tm) Server Message Queue Message Service.
     Connection myConn = myConnFactory.createConnection();
     myConn.getClientID();
     // Create a session within the connection.
     Session mySess = myConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
     myQueue = new com.sun.messaging.Queue("world");
     myConn.close();
     catch(Exception jmse){
     System.out.println("Exception occurred : " + jmse.toString());
jmse.printStackTrace();
# javac HelloWorldMessage.java
HelloWorldMessage.java:39: cannot find symbol
symbol : method createSession(boolean,int)
location: interface javax.jms.Connection
     Session mySess = myConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
     ^
1 error
# echo $CLASSPATH
.:/usr/java/default/j2sdkee1.3/lib/j2ee.jar:/usr/java/default/j2sdkee1.3/lib/:/root/MessageQueue/mq/lib/fscontext.jar:/usr/lib/jvm-exports/java-1.6.0-openjdk-1.6.0.0.x86_64/jndi.jar:/root/MessageQueue/mq/lib/jms.jar:/root/MessageQueue/mq/lib/imq.jar:/root/MessageQueue/mq/lib/jaxm-api.jar:/root/MessageQueue/mq/lib/imqxm.jar:/root/MessageQueue/mq/lib/imqservlet.jar
Edited by: 883631 on Sep 6, 2011 4:03 PM

You have an old j2ee.jar from 1.3 in your CLASSPATH.
Can you move jms.jar and imq.jar in front of that old j2ee.jar?
Thx/

Similar Messages

  • Java Studio Enterprise 8.1 and jdk1.6 - cannot find symbol

    Hi,
    I am using subj. The problem I have is that I declared 2-3 classes with methods in one package. I made an object of the class and use intellisense to navigate to the method I need but when I try to compile the code I have "cannot find symbol" error on the method I intellisensed to. It seems to me that it is IDE problem.
    Does anyone know how to work around it?
    The code is below, in case you are interested.
    package webservice;
    import java.io.*;
    public class Main {
    /** Creates a new instance of Main */
    public Main() {
    * @param args the command line arguments
    public static void main(String[] args) {
    String filename = null;
    String timestamp = null;
    try {
    Q q = new Q();
    timestamp = "2007-06-01";
    QList ql = q.getList(timestamp);
    System.out.println("--------------Ok-------------");
    catch(Exception e) {
    System.out.println("An Exception thrown in Main(). e = "+e.toString());
    package webservice;
    public class Q {
    public Q() {
    public QList getList(String timestamp) {
    QList result = null;
    return result;
    Thanks,
    Dmitry

    Thanks for that Kris.
    I found the root of my problem. In this example I used a remote webservice to retrieve some data. It happened to be that the generated class file from wsdl and my custom class had the same name.
    So, instead of reporting as ambiguous definition error the ide picked up the wrong class and did not find the method I intended to use.
    Hopefully it will help someone else having the same problem.
    Dmitry

  • Cannot find symbol error.. really stuck.

    I have a class named Rectangle.java. It is in a package "Geometry" together with Point.java and Line.java. But when I try to use Rectangle.java in my main program, MyRect.java, it gives me a "cannot find symbol" error, particularly the methods and sometimes the variables. I tried compiling just my Rectangle class and it compiled fine.. And I tried the Line and Point classes on another program and it works fine... well probably because the Line and Point classes are from a book(Ivor Horton's Beginning Java 2).. I am just starting out in Java. :)
    Rectangle.java
    package Geometry;
    public class Rectangle{
        public Point[] corner = new Point[4];
        public String name;
        public Rectangle(){
            corner[0].setPoints(0,0);
            corner[1].setPoints(1,0);
            corner[2].setPoints(0,1);
            corner[3].setPoints(1,1);
            name = new String("Unknown");
        public Rectangle(double point1_x,double point1_y,double point2_x, double point2_y, String Name){
            corner[0].setPoints(point1_x, point1_y);
            corner[3].setPoints(point2_x, point2_y);
            corner[1].setPoints(point2_x, point1_y);
            corner[2].setPoints(point1_x, point2_y);
            name = new String(Name);
        public Rectangle(final Rectangle oldRect, String Name){
            corner[0] = oldRect.corner[0];
            corner[3] = oldRect.corner[3];
            corner[1] = oldRect.corner[1];
            corner[2] = oldRect.corner[2];
            name = new String(Name);
        public double getWidth(){
            return corner[0].distance(corner[1]);
        public static void printRectangle(final Rectangle rect){
            for(int i= 0;i<4;i++){
                System.out.println("Corner"+(i+1)+" X: "+rect.corner.getX()+" Corner"+(i+1)+" Y: "+rect.corner[i].getY());
    System.out.println();
    public String toString(){
    return ("Name: "+name);
    }MyRect.java
    import Geometry.*;
    public class MyRect{
        public static void main(String[] args){
            Rectangle myRect = new Rectangle(0,0,2,1);
            Rectangle copyRect = new Rectangle(myRect);
            printRectangle(myRect);
            double width = myRect.getWidth();
    }and the errors:
    MyRect.java:4: cannot find symbol
    symbol  : constructor Rectangle(double,double,double,double,java.lang.String)
    location: class Rectangle
                    Rectangle myRect = new Rectangle(0.0,0.0,2.0,1.0,"My Rectangle")
                                       ^
    MyRect.java:9: cannot find symbol
    symbol  : variable name
    location: class Rectangle
                    System.out.println(myRect.name);
                                             ^
    2 errors

    Are you sure you have posted the whole content of MyRect.java
    import Geometry.*;
    public class MyRect{
        public static void main(String[] args){
            Rectangle myRect = new Rectangle(0,0,2,1);
            Rectangle copyRect = new Rectangle(myRect);
            printRectangle(myRect);
            double width = myRect.getWidth();
    }I don't see the following error line in the code you have given.
    MyRect.java:4: cannot find symbol
    symbol  : constructor Rectangle(double,double,double,double,java.lang.String)
    location: class Rectangle
                    Rectangle myRect = new Rectangle(0.0,0.0,2.0,1.0,"My Rectangle")
                                       ^
    MyRect.java:9: cannot find symbol
    symbol  : variable name
    location: class Rectangle
                    System.out.println(myRect.name);
                                             ^
    2 errors

  • Error: cannot find symbol method Text

    Hi
    I want to make an index for txt files by using Lucene, it got an error: cannot find symbol method Text. what is it about? Does it mean the Text is not in Field?
    thank you v much
    pls look into my code:
    package TestLucene;
    import java.io.File;
    import java.io.FileReader;
    import java.io.Reader;
    import java.util.Date;
    import org.apache.lucene.analysis.Analyzer;
    import org.apache.lucene.analysis.standard.StandardAnalyzer;
    import org.apache.lucene.document.Document;
    import org.apache.lucene.document.Field;
    import org.apache.lucene.index.IndexWriter;
    import org.apache.lucene.document.Fieldable;
    import java.io.Serializable;
    * This class demonstrate the process of creating index with Lucene
    * for text files
    public class Lucene {
         public static void main(String[] args) throws Exception{
              //indexDir is the directory that hosts Lucene's index files
            File   indexDir = new File("D:\\luceneIndex");
            //dataDir is the directory that hosts the text files that to be indexed
            File   dataDir  = new File("D:\\luceneData");
            Analyzer luceneAnalyzer = new StandardAnalyzer();
            File[] dataFiles  = dataDir.listFiles();
            IndexWriter indexWriter = new IndexWriter(indexDir,luceneAnalyzer,true);
            long startTime = new Date().getTime();
            for(int i = 0; i < dataFiles.length; i++){
                 if(dataFiles.isFile() && dataFiles[i].getName().endsWith(".txt")){
              System.out.println("Indexing file " + dataFiles[i].getCanonicalPath());
              Document document = new Document();
              Reader txtReader = new FileReader(dataFiles[i]);
              document.add(Field.Text("path",dataFiles[i].getCanonicalPath()));
              document.add(Field.Text("contents",txtReader));
              indexWriter.addDocument(document);
    indexWriter.optimize();
    indexWriter.close();
    long endTime = new Date().getTime();
    System.out.println("It takes " + (endTime - startTime)
    + " milliseconds to create index for the files in directory "
              + dataDir.getPath());

    Hal-.- wrote:
    I downloaded Lucene from its homepage, I have tried Lucene 2.3.0 and Lucene 2.2.0, but same errors occurs which is cannot find symbol method Text.
    I checked class Field under Lucene, it doesn't have Text function. Well there you go. You can't call methods that don't exist.
    What should I do to add two Fields "path" & "contents" into Document?It seems very likely that the object that represents an indexed document, has some way to express the concepts of "path" and "contents". You should probably just read the docs some more.
    But other than that I have no idea. Ask on a Lucene forum.

  • "cannot find symbol" error : method

    I'm playing with a sample serial port program and making some changes. I'm sure the error is painfully obvious, but I cannot resolve this:
    SimpleComm.java:122: cannot find symbol
    symbol : method SimpleComm()
    location: class SimpleComm
    public static void main(String[] args) {SimpleComm();
    ^
    what is going wrong? thanks
    sample code:
    import java.io.*;
    import java.util.*;
    import gnu.io.*;
    public class SimpleComm {
        static Enumeration           portList;
        static CommPortIdentifier portId;
        static String           messageString = "!00BCN10Dh";
        static SerialPort           serialPort;
        static OutputStream       outputStream;
        static boolean           outputBufferEmptyFlag = false;
        public SimpleComm()      {
             super();
         boolean portFound = false;
         String  defaultPort = "/dev/ttyS0";
         portList = CommPortIdentifier.getPortIdentifiers();
         while (portList.hasMoreElements()) {
             portId = (CommPortIdentifier) portList.nextElement();
             if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
              if (portId.getName().equals(defaultPort)) {
                  System.out.println("Found port " + defaultPort);
                  portFound = true;
                  try {
                   serialPort =
                       (SerialPort) portId.open("SimpleWrite", 2000);
                  } catch (PortInUseException e) {
                   System.out.println("Port in use.");
                   continue;
                  try {
                   outputStream = serialPort.getOutputStream();
                  } catch (IOException e) {}
                  try {
                   serialPort.setSerialPortParams(4800,
                                         SerialPort.DATABITS_8,
                                         SerialPort.STOPBITS_1,
                                         SerialPort.PARITY_NONE);
                  } catch (UnsupportedCommOperationException e) {}
                  try {
                       serialPort.notifyOnOutputEmpty(true);
                  } catch (Exception e) {
                   System.out.println("Error setting event notification");
                   System.out.println(e.toString());
                   System.exit(-1);
                  System.out.println(
                       "Writing \""+messageString+"\" to "
                   +serialPort.getName());
                  try {
                   outputStream.write(messageString.getBytes());
                  } catch (IOException e) {}
                  try {
                     Thread.sleep(2000);  // Be sure data is xferred before closing
                  } catch (Exception e) {}
                  serialPort.close();
                  System.exit(1);
         if (!portFound) {
             System.out.println("port " + defaultPort + " not found.");
         public static void main(String[] args) {SimpleComm();
         if (args.length > 0) {
             defaultPort = args[0];
        }

    try
    new SimpleComm()you are calling a constructor, not a method. This should wokr : )
    Hope this helps

  • Cannot find symbol: trying to index a method output

    The problem appears at the end of the code
    import java.util.*;
    public class Dreieck
      //Die Seiten des Dreiecks
      //Sides of triangle
       Object[] n= new Object[3];
       Object[] m= new Object[3];
       Object[] o= new Object[3];
      //Jede Seite erhält enthält 2 Eckpuckte und das anliegende Dreieck
      // Each side contains 2 corner ponts and the adjacent triangle
        Dreieck ( Punkt a, Punkt b, Punkt c, Dreieck e, Dreieck f, Dreieck g) {
        n[1]=a; n[2]=b; n[3]=e;
        m[1]=b; m[2]=c; m[3]=f;
        o[1]=c; o[2]=a; o[3]=g;
         int[] getside(Dreieck asker){
          if (n[3]== asker)
           return ((Punkt) m[2]).getposition();
         else if (m[3]== asker)
            return ((Punkt) o[2]).getposition();
         else if (o[3]== asker)
           return  ((Punkt) n[2]).getposition();
         // nur zum compilieren hinzugefügt
         else
          return ((Punkt) n[1]).getposition();
        int skaprod(int[] vec, int[] tor){
          return ((vec[1] * tor[1]) + (vec[2] * tor[2])) * Math.abs((vec[1] * tor[1]) + (vec[2] * tor[2])) /(((vec[1]*vec[1]) + (vec[2]*vec[2])) *((tor[1]*tor[1])+(tor[2]*tor[2])));
        int revskaprod(int[] vec, int[] tor){
          return ((vec[1] * (-tor[1])) + (vec[2] * (-tor[2]))) * Math.abs((vec[1] * (-tor[1])) + (vec[2] * (-tor[2]))) /(((vec[1]*vec[1]) + (vec[2]*vec[2])) *(((-tor[1])*(-tor[1]))+((-tor[2])*(-tor[2]))));
        void evertCheck(){
          int[] eins = ((Punkt) n[1]).getposition();
          int[] zwei = ((Punkt) n[2]).getposition();
          int[] drei = ((Punkt)  m[2]).getposition();
          int[] seiteA= {eins[1] -zwei[1],eins[2] -zwei[2]};
          int[] seiteB= {zwei[1] -drei[1],zwei[2] -drei[2]};
          int[] seiteC= {drei[1] -eins[1],drei[2]-eins[2]};
          int[] nachA1= {(e.asker(this))[1] -zwei[1],(e.asker(this))[2] -zwei[2]};
          //int[] NachB1=
          //int[] NachC1=
          //int[] NachA2=
          //int[] NachB2=
          //int[] NachC2=
    } Dreieck(triangle) is an incomplete class refering to the class Punkt(point):
    import java.util.*;
    public class Punkt
      int[] position = new int [2];
      LinkedList nachbarn = new LinkedList();
      Punkt(int a, int b){
      position[1]=a; position[2]=b; }
      int[] getposition() { return position; }
      void changeposition(int c,int d) {
       position[1]+=c; position[2]+=d; }
        }Anm: nachbarn = neighbours
    I am trying to calculate the vectors, to calculate the scalar products, to get the cos of the angle, to check for certain conditions occuring XD
    This class is part of an idea for a certain 2D physics system, basically instead of using collision checks or forcefields I connect the points with a network of lines
    and only let the points interact with their direct neighbours while also allowing "signals"to travel trough connections.
    Why do I do this? So that the O(n)= n (the needed processing power is only linearly dependant on number of points)
    Whats the challenge? Well its not easy to find conditions for reconnections so that points that are connected are relaitvely near to each other.
    Why such imprecision? Game phsysics does not always have to be precise besides when I operate with a large number of points things smoothen up statistically.
    Game physics? I have some interest in artificial life this system is part of me trying to write an artificial life simulation.
    Of course my current version is pretty clumsy but i hope it can be streamlined for processing power.

    I guess you interpreted "post" as this topic, when I meant the reply I gave you, then it would make sense you assume I have withold information.
    Cause there really is no specific information for me to provide, it was a simple forward problem of a cannot find symbol error.
    (I know that help can only be provided with enough information, thats why I gave you the whole code stated my intentions in the title as well as additional text etc., so you say thats the wrong "kind" of information?)
    As for your argument against compiling I must admit I do not understand it cause its a copy, paste and click action to compile the code.
    Ah but well thats not so important did not want to ruin your mood actually found the solution :)
    int[] nachA1= {(((Dreieck) n[3]).getside(this))[1] -zwei[1], (((Dreieck) n[3]).getside(this))[2]-zwei[2]};Edited by: casualPhilosoph on Jan 23, 2009 2:28 PM

  • Static method throwing "cannot find symbol - method"

    This is an assignment for school. I'm in my second semester of object oriented programming. Here is the method causing the error when compiled in the test case:
        public void testRead()
            Company aCompany = buildCompany();
            aCompany.writeToFile("CompanyDatabase.txt");
            Company bCompany = new BooksAndMore();
            bCompany = readFromFile("CompanyDatabase.txt");
            assertTrue(aCompany.equals(bCompany));
        }Error thrown is "cannot find symbol - method readFromFile(java.lang.String). Here is the method being called:
    {code} public static Company readFromFile(String fileName)
    Company company = new BooksAndMore();
    FileInputStream fis = null;
    ObjectInputStream in = null;
    try
    fis = new FileInputStream(fileName);
    in = new ObjectInputStream(fis);
    company = (Company)in.readObject();
    in.close();
    catch (IOException ex)
    ex.printStackTrace();
    catch (ClassNotFoundException ex)
    ex.printStackTrace();
    return company;
    }{code}
    What am I doing wrong?

    are testRead() and readFromFile() in the same class?
    also, the first line is pointless:
    Company bCompany = new BooksAndMore();
    bCompany = readFromFile("CompanyDatabase.txt");Since the second line calls a method that creates a new BooksAndMore object, there's no point creating one in the first line...it will just be replaced by the new one.
    Company bCompany = readFromFile("CompanyDatabase.txt");...assuming that your readFromFile() method is in the same class. If not, you need to call the method on the class.

  • When creating a remote address in a pot or other objects you cannot use a / for a address??? my ladders addresses contain such ////// symbols for some addresses?​??

    when creating a remote address in a pot or other objects you cannot use a  /  for a address??? my ladders addresses contain such ////// symbols for some addresses???

    On the AB object, "f" is a float and cannot address individual bits.
    Otherwise, you would replace the "/" with an "_".
    Forshock - Consult.Develop.Solve.

  • [Basic For Loop] "cannot find symbol" in ForUpdate part

    Dear All,
    I wonder why the following is an error:
         for ( int x=0; x < 10; x = y ) {
              int y = x + 1;
         }The formal specification is
    for ( ForInitopt ; Expressionopt ; ForUpdateopt ) Statement
    However, as specified in http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.14, and if you disassemble the bytecode,
    "ForUpdate" part is always evaluated after the included statement,
    In other words, it is evaluated as:
         for ( ForInitopt ; Expressionopt ; ) {
              Statement(s);
              ForUpdateopt
         }Or
         for ( int x=0; x < 10;  ) {
              int y = x + 1;
              x = y;
         }So, the only reason I find "cannot find symbol" reasonable is just human convinience, but not technically correct.
    What do you think?
    Many thanks.

    Very good asif but once again you have not answered
    the question.
    why?My answer may be partialy correct.But you answer is fully correct.
    And don't appreciate me.I'm not good at programming(in Java) like you.
    The variable y has been declared inside the loop so
    you cannot access in the loop header.
    int y = 0;
    for ( int x=0; x < 10; x = y ) {
    y =  x + 1;
    /code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java Error : cannot find symbol , symbol : class (jdk 1.6.0)

    Dear All,
    Please help me.
    I am running javac from a .bat file and i set the classpath in the bat file as follows.
    echo on
    :start
    set classpath = "C:\Program Files\Java\jdk1.6.0\bin;"
    set classpath = "C:\Program Files\Java\jdk1.6.0\jre\..\lib\tools.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\i18n.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0\jre\classes;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\ldapsec.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\mysql-connector-java-5.0.0-beta-bin.jar;C:\Program Files\Java\jdk1.6.0\jre\lib\ext\sunjce_provider.jar; C:\Program Files\Java\jdk1.6.0\ideset\system;C:\Program Files\Java\jdk1.6.0\ideset\system;C:\Program Files\Java\jdk1.6.0\studio\system;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\j2ee-1.3.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\jaas-1.0.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\autoload\activation.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\jms-1.0.2b.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\jta-spec1_0_1.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\autoload\mail.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\AbsoluteLayout.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\sql.jar;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\rowset.jar;C:\Program Files\Java\jdk1.6.0\studio\lib\ext\jdbc20x.zip;C:\Program Files\Java\jdk1.6.0\studio\modules\ext\servlet-2.3.jar;C:\Program Files\Java\jdk1.6.0\studio\beans\TimerBean.jar;c:\Program Files\Java\jdk1.6.0\ideset\tomcat401_base;C:\sms\com\;"
    cd C:\sms
    javac mainP.java
    pause
    i have few class files which are inherited to the main program using ' import com.Connection; '
    i am getting errors like
    mainP.java:482: cannot find symbol
    symbol : class Connection
    location: class mainP
    Connection connection = new Connection(ipAddress, port);
    I think it is because of some classpath error.
    please advice me.......
    Viju

    Actually, you have NO CLUE what he's trying to doActually he said what he is trying to do in his posting. It's no mystery. But that's all the information that's available. If you know something that isn't posted here why not say so?
    Your reply was a snide, rude, "You're stupid for doing it that way" answerMy reply was neither snide nor rude and implied none of what you impute to it. It was a proper and constructive suggestion. You are entitled to disagree with it, but that doesn't justify this immoderate outburst.
    Bottom line is, you chose to be nastyBottom line is you're just making this up. You are imputing motives to me without evidence. Don't do that.
    You are the type of person that makes searching forums and posting questions for assistance a near waste of time.I doubt that you'll find many regulars here that would agree with that assertion. When you have made over 16,000 posts here over ten years as I have, come back and we'll discuss it some more.
    Go back to grade school and ...I suggest you try it yourself. You're not adding anything except noise to the discussion. Try curbing your temper, and while you're at it have a good look at the Code of Conduct for these forums. You're verging on personal abuse here.
    And, additionally, I've used ANT in the past. Batch files are FAR AND AWAY easier to set up.In your opinion. I disagree entirely, and I have eleven years' experience with Java to back it up.
    As for CLASSPATH, I haven't done anything about setting it beyond installing the JDK since about 1999, and it has a dot in it as we speak.

  • Need help with class info and cannot find symbol error.

    I having problems with a cannot find symbol error. I cant seem to figure it out.
    I have about 12 of them in a program I am trying to do. I was wondering if anyone could help me out?
    Here is some code I am working on:
    // This will test the invoice class application.
    // This program involves a hardware store's invoice.
    //import java.util.*;
    public class InvoiceTest
         public static void main( String args[] )
         Invoice invoice1 = new Invoice( "1234", "Hammer", 2, 14.95 );
    // display invoice1
         System.out.println("Original invoice information" );
         System.out.println("Part number: ", invoice1.getPartNumber() );
         System.out.println("Description: ", invoice1.getPartDescription() );
         System.out.println("Quantity: ", invoice1.getQuantity() );
         System.out.println("Price: ", invoice1.getPricePerItem() );
         System.out.println("Invoice amount: ", invoice1.getInvoiceAmount() );
    // change invoice1's data
         invoice1.setPartNumber( "001234" );
         invoice1.setPartDescription( "Yellow Hammer" );
         invoice1.setQuantity( 3 );
         invoice1.setPricePerItem( 19.49 );
    // display invoice1 with new data
         System.out.println("Updated invoice information" );
         System.out.println("Part number: ", invoice1.getPartNumber() );
         System.out.println("Description: ", invoice1.getPartDescription() );
         System.out.println("Quantity: ", invoice1.getQuantity() );
         System.out.println("Price: ", invoice1.getPricePerItem() );
         System.out.println("Invoice amount: ", invoice1.getInvoiceAmount() );
    and that uses this class file:
    public class Invoice
    private String partNumber;
    private String partDescription;
    private int quantityPurchased;
    private double pricePerItem;
         public Invoice( String ID, String desc, int purchased, double price )
              partNumber = ID;
         partDescription = desc;
         if ( purchased >= 0 )
         quantityPurchased = purchased;
         if ( price > 0 )
         pricePerItem = price;
    public double getInvoiceAmount()
         return quantityPurchased * pricePerItem;
    public void setPartNumber( String newNumber )
         partNumber = newNumber;
         System.out.println(partDescription+" has changed to part "+newNumber);
    public String getPartNumber()
         return partNumber;
    public void setDescription( String newDescription )
         System.out.printf("%s now refers to %s, not %s.\n",
    partNumber, newDescription, partDescription);
         partDescription = newDescription;
    public String getDescription()
         return partDescription;
    public void setPricePerItem( double newPrice )
         if ( newPrice > 0 )
    pricePerItem = newPrice;
    public double getPricePerItem()
    return pricePerItem;
    Any tips for helping me out?

    System.out.println("Part number:
    "+invoice1.getPartNumber;
    The + sign will concatenate invoice1.getPartNumber()
    after "Part number: " forming only one String.I added the plus sign and it gives me more errors:
    C:\>javac InvoiceTest.java
    InvoiceTest.java:16: operator + cannot be applied to java.lang.String
            System.out.println("Part number: ",   + invoice1.getPartNumber() );
                                                  ^
    InvoiceTest.java:17: cannot find symbol
    symbol  : method getPartDescription()
    location: class Invoice
            System.out.println("Description: ", + invoice1.getPartDescription() );
                                                          ^
    InvoiceTest.java:17: cannot find symbol
    symbol  : method println(java.lang.String,int)
    location: class java.io.PrintStream
            System.out.println("Description: ", + invoice1.getPartDescription() );
                      ^
    InvoiceTest.java:18: cannot find symbol
    symbol  : method getQuantity()
    location: class Invoice
            System.out.println("Quantity: ", + invoice1.getQuantity() );
                                                       ^
    InvoiceTest.java:18: cannot find symbol
    symbol  : method println(java.lang.String,int)
    location: class java.io.PrintStream
            System.out.println("Quantity: ", + invoice1.getQuantity() );
                      ^
    InvoiceTest.java:19: cannot find symbol
    symbol  : method println(java.lang.String,double)
    location: class java.io.PrintStream
            System.out.println("Price: ", + invoice1.getPricePerItem() );
                      ^
    InvoiceTest.java:20: cannot find symbol
    symbol  : method println(java.lang.String,double)
    location: class java.io.PrintStream
            System.out.println("Invoice amount: ", + invoice1.getInvoiceAmount() );
                      ^
    InvoiceTest.java:24: cannot find symbol
    symbol  : method setPartDescription(java.lang.String)
    location: class Invoice
            invoice1.setPartDescription( "Yellow Hammer" );
                    ^
    InvoiceTest.java:25: cannot find symbol
    symbol  : method setQuantity(int)
    location: class Invoice
            invoice1.setQuantity( 3 );
                    ^
    InvoiceTest.java:30: operator + cannot be applied to java.lang.String
            System.out.println("Part number: ", + invoice1.getPartNumber() );
                                                ^
    InvoiceTest.java:31: cannot find symbol
    symbol  : method getPartDescription()
    location: class Invoice
            System.out.println("Description: ", + invoice1.getPartDescription() );
                                                          ^
    InvoiceTest.java:31: cannot find symbol
    symbol  : method println(java.lang.String,int)
    location: class java.io.PrintStream
            System.out.println("Description: ", + invoice1.getPartDescription() );
                      ^
    InvoiceTest.java:32: cannot find symbol
    symbol  : method getQuantity()
    location: class Invoice
            System.out.println("Quantity: ", + invoice1.getQuantity() );
                                                       ^
    InvoiceTest.java:32: cannot find symbol
    symbol  : method println(java.lang.String,int)
    location: class java.io.PrintStream
            System.out.println("Quantity: ", + invoice1.getQuantity() );
                      ^
    InvoiceTest.java:33: cannot find symbol
    symbol  : method println(java.lang.String,double)
    location: class java.io.PrintStream
            System.out.println("Price: ", + invoice1.getPricePerItem() );
                      ^
    InvoiceTest.java:34: cannot find symbol
    symbol  : method println(java.lang.String,double)
    location: class java.io.PrintStream
            System.out.println("Invoice amount: ", + invoice1.getInvoiceAmount() );
                      ^
    16 errors

  • "cannot find symbol" errormessage

    Hello
    I want to keep my ArrayList information private so I declared:
    private ArrayList<Integer> locationAddress;I created the ArrayList object in the constructor     public SimpleDotCom()
               locationAddress = new ArrayList<Integer>();
          }I was using a remove() method available with the ArrayList class.
    I decided to encapsulate the remove() method in
      public void removeLocationIndex(int index)
            locationAddress.remove(index);
          }but when I try to call the method by saying:   locationAddress.removeLocationIndex(index); I get an error message that says:
    cannot find symbol; symbol : method removeLocationIndex(int), location: class java.util.ArrayList<java.lang.Integer> at line 47
    Below is the class.
    Thank you for your assistance  public class SimpleDotCom
           private ArrayList<Integer> locationAddress;
         public SimpleDotCom()
               locationAddress = new ArrayList<Integer>();
          public void storeLocationAddress(int location)
            locationAddress.add(location);
          public void removeLocationIndex(int index)
            locationAddress.remove(index);
          static final int  INCORRECTGUESS = 2;
          static final int GOODGUESS = 1 ;
          static final int WIN = 0 ;
         public int checkIfGuessIsCorrect(int userGuess)
            int result = INCORRECTGUESS;
          /* find out if the user guess is in the ArrayList
          by asking for it's index. If it's not in the list,
          then indexOf() returns a -1 */
          int index = locationAddress.indexOf(userGuess);
          if (index == -1)
              result = INCORRECTGUESS;
              System.out.print(" The result is a " + result + "... an Incorrect Guess !");
          if(index >= 0)
            /* if the index is zero or greater, it's in the list
            so remove it */
            locationAddress.removeLocationIndex(index);
            /* if the list isEmpty() then
               that was the "WINning" ing guess ! */
            if(locationAddress.isEmpty())
              result = WIN;
              System.out.print("  you WIN ! ");
            else
              result = GOODGUESS;    // 1 indicates a "hit"
              System.out.print("  The result is a  " + result + " a GOOD GUESS");
          } // end outer if
          return result;
        }//end method
      } // end class

    locationAddress is of type ArrayList. ArrayList doesn't have a method called removeLocationIndex(). You can call that method on an object of type SimpleDotCom.
    In a member method (such as checkIfGuessIsCorrect()) you can call this.removeLocationIndex() or simply removeLocationIndex() - the "this." is implicit. Which you prefer is up to you - some people see an explicit "this." as improving readability in some cases, some feel the extra typing is a sign of a newbie.

  • Java cannot find symbol [Color type]

    * Parked car class
    * class properties are
    * - Car Color
    * - Car Model
    * - Car Make
    * - License Number
    * - Number of minutes car has been parked
    public class ParkedCar {
    // Field declarations for class ParkedCar
    // declare color datatype (enum)
    Color CarColor;
    String CarModel,
    CarMake,
    LicenseNumber;
    double TimeParkedMinutes;
    public ParkedCar() {
    CarColor = Color.NOTSPECIFIED;
    CarModel = "NOT SPECIFIED";
    CarMake = "NOT SPECIFIED";
    LicenseNumber = "NOT SPECIFIED";
    TimeParkedMinutes = 0.0;
    } // end no arg constructor method for ParkedCar class
    public ParkedCar(Color parkedColor, String parkedModel, String parkedMake, String parkedLicense, double parkedMinutes) {
    CarColor = parkedColor;
    CarModel = parkedModel;
    CarMake = parkedMake;
    LicenseNumber = parkedLicense;
    TimeParkedMinutes = parkedMinutes;
    } // end constructor ParkedCar
    public Color getColor() {
    return CarColor;
    public String getModel() {
    return CarModel;
    public String getMake() {
    return CarMake;
    public String getLicenseNumber() {
    return LicenseNumber;
    public double getTimeParkedMinutes() {
    return TimeParkedMinutes;
    } // end class ParkedCar
    I keep getting this compilation error
    ParkedCar.java:21: cannot find symbol
    symbol  : class Color
    location: class Color.ParkedCar
    Color CarColor;
    The enumerated data type Color is declared within a separate class file. This code will compile when Color is defined within this class. Seems that enums are somewhat of a strange breed. Any ideas?
    Last edited by estex198 (2009-04-06 17:07:43)

    found some example code. I'm definately doing something wrong here. Do I need an import statement somewhere? I found some example code on a tutorial site. The enumerated data type Days is only accessible to members of EnumTest if its declaration is within the class EnumTest (as opposed to storing the enum declaration in its own .java file.
    public class EnumTest {
    public enum Day {
    SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
    THURSDAY, FRIDAY, SATURDAY
    Day day;
    public EnumTest(Day day) {
    this.day = day;
    public void tellItLikeItIs() {
    switch (day) {
    case MONDAY: System.out.println("Mondays are bad.");
    break;
    case FRIDAY: System.out.println("Fridays are better.");
    break;
    case SATURDAY:
    case SUNDAY: System.out.println("Weekends are best.");
    break;
    default: System.out.println("Midweek days are so-so.");
    break;
    public static void main(String[] args) {
    EnumTest firstDay = new EnumTest(Day.MONDAY);
    firstDay.tellItLikeItIs();
    EnumTest thirdDay = new EnumTest(Day.WEDNESDAY);
    thirdDay.tellItLikeItIs();
    EnumTest fifthDay = new EnumTest(Day.FRIDAY);
    fifthDay.tellItLikeItIs();
    EnumTest sixthDay = new EnumTest(Day.SATURDAY);
    sixthDay.tellItLikeItIs();
    EnumTest seventhDay = new EnumTest(Day.SUNDAY);
    seventhDay.tellItLikeItIs();
    If I were to store the enum declaration in its own file then it should look something like this(?):
    public enum Day {
    SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
    THURSDAY, FRIDAY, SATURDAY
    Thanks for your time.

  • Max3.java:17: cannot find symbol

    Hi guys,
    Need some help here..
    This is my code:
    import java.util.Scanner;
    import static java.lang.Math.*;
    public class Max3{
         public static void main (String[] args)     {
         Scanner kb = new Scanner(System.in);
         System.out.print ("Enter 1st number:");
         int first = kb.nextInt();
         System.out.print ("Enter 2nd number:");
         int second = kb.nextInt();
         System.out.print ("Enter 3rd number:");
         int third = kb.nextInt();
         System.out.println (Math.max(first,second,third));
    ===================================================================
    This is the error im getting :
    Max3.java:17: cannot find symbol
    symbol : method max(int,int,int)
    location: class java.lang.Math
    System.out.println (Math.max(first,second,third));
    ^
    1 error
    ====================================================================
    Do i need to import the math? i read from somewhere that Math class is contained in the Java.lang package, and we therefore don't have to import it ...

    I tried again, same error.
    Edited Maths.max to only max
    ========================================
    import java.util.Scanner;
    import static java.lang.Math.*;
    public class Max3{
         public static void main (String[] args)     {
         Scanner kb = new Scanner(System.in);
         System.out.print ("Enter 1st number:");
         int first = kb.nextInt();
         System.out.print ("Enter 2nd number:");
         int second = kb.nextInt();
         System.out.print ("Enter 3rd number:");
         int third = kb.nextInt();
         System.out.println (max(first,second,third));
    =================================================
    Error:
    C:\kenny>javac Max3.java
    Max3.java:17: cannot find symbol
    symbol : method max(int,int,int)
    location: class Max3
    System.out.println (max(first,second,third));
    ^
    1 error
    Thanks for spending some time on this!

  • Cannot find symbol: ServletFileUpload

    Hey Guys/Gals,
    Im attempting to setup commons FileUpload. I am following the instructions from the apache commons page but am having some minor first timer problems :)
    fileUpload.jsp
    <%@ page import="org.apache.commons.fileupload.servlet.*" %>
    <%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
    <%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
    <%@ page import="org.apache.commons.fileupload.*"%>
    <%@ page import="org.apache.commons.*"%>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.portlet.*" %>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <%
            // Check that we have a file upload request
            boolean isMultipart = ServletFileUpload.isMultipartContent(request);
            if(isMultipart==true){
                System.out.println("isMultipart true");
            %>
        </body>
    </html>I got the code directly from the apache commons site, i have the following .jar and .zip files in the classpath of both the application and the web server (common/lib).
    commons-io-1.4.jar
    commons-fileupload-1.1.1.zip
    portlet-api.jar
    And the error is the following:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    C:\Documents and Settings\rquigley\.netbeans\5.5.1\apache-tomcat-5.5.17_base\work\Catalina\localhost\PhotoAlbum\org\apache\jsp\FileUpload\fileUpload_jsp.java:6: package org.apache.commons.fileupload.servlet does not exist
    import org.apache.commons.fileupload.servlet.*;
    ^
    An error occurred at line: 26 in the jsp file: /FileUpload/fileUpload.jsp
    Generated servlet error:
    C:\Documents and Settings\rquigley\.netbeans\5.5.1\apache-tomcat-5.5.17_base\work\Catalina\localhost\PhotoAlbum\org\apache\jsp\FileUpload\fileUpload_jsp.java:68: cannot find symbol
    symbol  : variable ServletFileUpload
    location: class org.apache.jsp.FileUpload.fileUpload_jsp
            boolean isMultipart = ServletFileUpload.isMultipartContent(request);
                                  ^
    2 errors
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)I send a multipart post from another page:
    FORM ACTION="FileUpload/fileUpload.jsp" METHOD="post" ENCTYPE="multipart/form-data">
                <input type="file" name="file" value=""/>
                <input type="submit" name="submit" value="Submit"/>
    </form>Any idears would be great.
    Thanks
    Rob

    dobsun wrote:
    I got the code directly from the apache commons site, i have the following .jar and .zip files in the classpath of both the application and the web server (common/lib).
    commons-io-1.4.jar
    commons-fileupload-1.1.1.zip
    portlet-api.jarA zip file is not a jar file. Extract the zip to get the jar file.

Maybe you are looking for

  • Error in EDI sales order creation.

    Hi SAP gurus, Presently we are having a scenario, While creating a sales order through EDI we are presently getting an error Status - 51 "Update Error, Transaction VA01". When I again reprocess the idoc, It is creating order successfully. This is a r

  • Expose Preferences Keep Changing Themselves

    I have Active Screen Corners activated for Expose. However the upper left corner keeps unactivating itself. Is there any way for me to track this preference in the system to see what is modifying it?

  • Screen blinks/flashes upon wake from sleep. is this normal?

    I just got my Macbook a few days ago and started to notice that my screen flashes or blinks when it wakes from sleep. I have searched on Google and haven't seen any one post about it so I'm guessing this is normal. This is not the flicker of brightne

  • Editor has stopped working error

    Upon opening my Adobe Photoshop 11 the programs error says "Editor has stopped working" closing the program.  I really need my editor, can someone help me?

  • ABOUT THE TWO COUNTERS OF THE AT-MIO-16-​E

    This is my question.I've an AT-MIO-16-E and I need the two counters to work simultaneously to acqquire two frequencies countinously.I can't find a way to let them work countinously:they always stop after an acquisition.I've tried to use a while loop