Javac compiler Error - cannot resolve symbol - symbol  StringBuilder?

Hi ,
I am using hp - ux system with java version "1.4.2.06". when i try to compile a program called CharSequenceDemo.java which is found in the java tutorials at this link
[CharSequenceDemo.java|http://java.sun.com/docs/books/tutorial/java/IandI/examples/CharSequenceDemo.java]
i get the following error:
$/opt/java1.4/bin/javac CharSequenceDemo.java
CharSequenceDemo.java:38: cannot resolve symbol
symbol : class StringBuilder
location: class CharSequenceDemo
StringBuilder sub =
^
CharSequenceDemo.java:39: cannot resolve symbol
symbol : class StringBuilder
location: class CharSequenceDemo
new StringBuilder(s.subSequence(fromEnd(end), fromEnd(start)));
^
CharSequenceDemo.java:44: cannot resolve symbol
symbol : class StringBuilder
location: class CharSequenceDemo
StringBuilder s = new StringBuilder(this.s);
^
CharSequenceDemo.java:44: cannot resolve symbol
symbol : class StringBuilder
location: class CharSequenceDemo
StringBuilder s = new StringBuilder(this.s);
^
4 errors
Please help on how to compile this program.

I've been struggling with the same issue. The difference is that my system says I'm using version 1.6.0_05. I've tried running jucheck.exe. It tells me I've got the latest version installed.
Here is the code:
import java.lang.StringBuilder;
import java.util.Formatter;
   public class UsingFormatter {
     public static void main(String[] args) {
       if (args.length != 1) {
         System.err.println("usage: " +
           "java format/UsingFormatter <format string>");
         System.exit(0);
       String format = args[0];
       StringBuilder stringBuilder = new StringBuilder();
       Formatter formatter = new Formatter(stringBuilder);
       formatter.format("Pi is approximately " + format +
         ", and e is about " + format, Math.PI, Math.E);
       System.out.println(stringBuilder);
   }When I type javac UsingFormatter.java, I get:
UsingFormatter.java:1: cannot resolve symbol
symbol : class StringBuilder
location: package lang
import java.lang.StringBuilder;
^
UsingFormatter.java:2: cannot resolve symbol
symbol : class Formatter
location: package util
import java.util.Formatter;
^
UsingFormatter.java:14: cannot resolve symbol
symbol : class StringBuilder
location: class UsingFormatter
StringBuilder stringBuilder = new StringBuilder();
^
UsingFormatter.java:14: cannot resolve symbol
symbol : class StringBuilder
location: class UsingFormatter
StringBuilder stringBuilder = new StringBuilder();
^
UsingFormatter.java:15: cannot resolve symbol
symbol : class Formatter
location: class UsingFormatter
Formatter formatter = new Formatter(stringBuilder);
^
UsingFormatter.java:15: cannot resolve symbol
symbol : class Formatter
location: class UsingFormatter
Formatter formatter = new Formatter(stringBuilder);
^
6 errors
The compiler refuses to recognize the symbols StringBuilder and Formatter.
I have spent hours googling for an answer and trying every suggestion. Nothing works, not even the one about dropping the computer from the rooftop.
Ultimately, what I'm trying to accomplish (in a different program) is to use a text file as a form letter template and replace the %s placeholders with stings from my form object.
Any advice?
Edited by: javastudent_99 on Apr 3, 2008 1:48 PM

Similar Messages

  • Compiling error - cannot resolve symbol

    Hi,
    I am working on writing out this basic code for a project. When I compile, I get an error "Cannot resolve symbol" for the gpa variable. Please help!
    My intention is to use the hours and points from the crHours and nbrPoints methods, and use them to calculate GPA in the grPtAvg method:
    public class Student
         public static void main(String[]args)
    idNum();
    crHours();
    nbrpoints();
    gpa = grPtAvg(hours, points);
    System.out.println("Student's GPA is " + gpa);
    public static void idNum()
    int id = 2520;
    System.out.println("Student's ID is " + id);
    public static float crHours()
    float hours = 5;
    System.out.println("Student's credit hours are " + hours);
    return hours;
    public static float nbrpoints()
    float points = 22;
    System.out.println("Student's earned points are " + points);
    return points;
    public static float grPtAvg(float hours, float points)
    float gpa;
    gpa = points / hours;
    System.out.println("Student's computed GPA is " + gpa);
    return gpa;

    That's because you're doing the same thing (in a somewhat different way) with those.
    The variables: hours and points have already been returned to main methd, right?Yes, but then the main method ignores them.
    So, they should be available at this point in the code, is that right?Available in the sense that you can read them, but not in the sense that there are hours and points variables within scope in the main method.
    You want to do this:
    public static void main(String[] args) {
       idNum();
       float hours = crHours();
       float points = nbrpoints();
       //create a new float
       float myComputetdGpa = grPtAvg(hours, points);
       System.out.println("Student's GPA is " + myComputedGpa);
    }

  • Compiler error cannot resolve symbol

    Hi people,
    i'm having this compile time error that, when i create a class and calling that class in another class gives the error cannot resolve symbol classname and it also happened when i created a bean and referencing the bean class in another bean when i'm using Jsp. thanks in advance.

    It would be helpful if you post the exact error message. If you use a system Classpath, then it must contain the root directory for the package directory(s).
    For example, if the source code for a file starts with
    package my.package;
    and you have a directory structure c:\myjava\classes\my\package then the Classpath must contain c:\myjava\classes.

  • Compile error - cannot resolve symbol

    Hello,
    I am trying this code although I get compile errors as stated.
    import java.util.Scanner;
    * Write a program that reads 10 numbers from the keyboard into
    * an array and then prints the list of numbers
    * Modify the above program so that it prints the numbers in reverse order
    class Keyboard
      public static void main (String[] argStrings)
         System.out.println("Enter 10 numbers please");
         Scanner scan = new Scanner(System.in);
         int[] newArray = new int[10];
         for(int i = 0; i < 10; i++)
              newArray[i] = scan.nextInt();
         System.out.println();
         for(int i = 9; i > 0; i--)
              System.out.print(newArray);
    System.out.println();
    I have googled for solutions but have had no luck or could not understand.
    Please could someone explain what is going on.
    Cheers

    E:\Documents and Settings\John\Desktop\Computing\Programming\Weeks\Week11\Keyboard.java:1: cannot resolve symbol
    symbol : class Scanner
    location: package util
    import java.util.Scanner;
    ^
    E:\Documents and Settings\John\Desktop\Computing\Programming\Weeks\Week11\Keyboard.java:15: cannot resolve symbol
    symbol : class Scanner
    location: class Keyboard
         Scanner scan = new Scanner(System.in);
    ^
    E:\Documents and Settings\John\Desktop\Computing\Programming\Weeks\Week11\Keyboard.java:15: cannot resolve symbol
    symbol : class Scanner
    location: class Keyboard
         Scanner scan = new Scanner(System.in);
    ^
    3 errors
    Tool completed with exit code 1
    cheers

  • Stop a known compile error (Cannot resolve symbol)

    I get a known compile error is their some way to stop this.
    Basically I call a reader in a method in my main class to be used in a threaded search.
    I only reset the reader when I want to so I can search for further results without starting from the start of the file again.
    I know that there is no way for the program to get to this point without having the filereader class loaded so I want to stop this error.
    Im thinking their is probably a way of putting in an if statement around my call to the search thread to check the object is in memory.
    Thanks for the help in advance.

    I get a known compile error is their some way to stop this. Yes, fix the code so it's syntactically correct. That's the only way to get rid of compiler errors.
    Im thinking their is probably a way of putting in an
    if statement around my call to the search thread to
    check the object is in memory.This isn't C/C++ with #define and #ifdef for preprocessor directives. What are you thinking?
    Fix your code and the compiler errors will go away.
    %

  • JSP Compilation Problem - Cannot Resolve Symbol

    I cannot see the problem. Maybe I am not sober at 2:30 am.
    <%
    Collection postBeans = ( Collection )request.getAttribute( "PostBeans" );
    Iterator iterator = postBeans.iterator();
    int i = 0;
    while( iterator.hasNext() )
          PostBean postBean = (PostBean)iterator.next();
       i++;
       String background;
       if ( postBean.getParentPostID() == 0 )
          background = "#FFCE9C";
       else
          if ( ( i%2 ) != 0 )
             background = "#EEEEEE";
          else
             background = "#FFFFFF";
    %>
    <table width="95%" border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#999999">
      <tr bgColor=<%=background%>>
      </tr>
    </table>I got compilation error: cannot resolve symbol
    symbol: background

    I put the variable 'background' outside the while loop. The 'cannot resolve symbol' problem is gone. But, I got another compilation error:
    >
    unexpected type
    required: variable
    found : value
    out.write("\r\n }\r\n i++;\r\n if ( postBean.getParentPostID() == 0 ) \r\n {\r\n background = \"#FFCE9C\";\r\n }\r\n else \r\n {\r\n if ((i%2) != 0) \r\n {\r\n background = \"#EEEEEE\";\r\n } \r\n else \r\n {\r\n background = \"#FFFFFF\";\r\n }\r\n }\r\n%>\r\n");
    The code looks like:
    <%
    String background;
    Collection postBeans = ( Collection )request.getAttribute( "PostBeans" );
    Iterator iterator = postBeans.iterator();
    int i = 0;
    while( iterator.hasNext() )
          PostBean postBean = (PostBean)iterator.next();
       i++;
       if ( postBean.getParentPostID() == 0 )
          background = "#FFCE9C";
       else
          if ( ( i%2 ) != 0 )
             background = "#EEEEEE";
          else
             background = "#FFFFFF";
    %>
    <table width="95%" border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#999999">
      <tr bgColor=<%=background%>>
      </tr>
    </table>

  • When i try to use max() & pow() in jdbc i get error "cannot resolve symbol"

    hi,
    when i tried to use pow() & max() in my jdbc programme i got compilation error "cannot resolve symbol".
    even i have imorted java.math
    this is the sample.
    pr1= (fy/(L*B*pow(10.0,-6.0))+((6*mx)/(L*B*B*pow(10.0,-6.0)))+((6*mz)/(B*L*L*pow(10.0,-6.0))));
    all of above are double.
    and with max();
    pr=max(pr1,pr2);
    all of above are double.
    please help.
    thanks in advance.
    satish

    hi
    Hartmut
    thanks hartmut;
    i am new in java so i have some problems, but thanks for helping me.
    please help me again.
    as i have already posted another probleme which i have with selecting 1000 rows 1 by 1 from a table & manipulate 1 by 1 on that and then store all manipulated row to another table.
    when i tried to do so i am able to select only 600 rows and manipulate them & store them.
    i did not get any exception or any error.
    can this possible that microsoft access driver has not that much capacity to provide 1000 rows or it is problem with jdbc.
    please help.
    satish
    thanks again.

  • Error:cannot resolve Symbol class"name"

    when I have compiled Bean class named SlBean which has primary class named pk, I recevied following error message(I compiled pk class without error) :
    cannot resolve symbol
    symbol : class pk
    location: class SlBean
    public pk ejbCreate(

    Sorry , its not classpath problem. You have to simply import the pk class if its in any package. I am assuming you have packaged your pk class with ejb jar file.
    for eg. if your class is
    package abc.xyz
    public class pk
    then in your bean class import
    import abc.xyz.pk;
    --Ashwani                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I am getting an error cannot resolve symbol variable?

    I am trying to run a PdfFormGenerator.java file and am using the iText API, hence have included
    the iText.jar file. When I compile the code I keep getting the following two errors:
    cannot resolve symbol variable CLASS_LOCATION
    cannot resolve symbol variable FORM_LOCATION
    can anyone guide me what I may have done wrong.
    Thanks,
    Zub

    Hi! To be more specific its these to line of the code is were I am going the errors:
        private String classLocation = Constants.CLASS_LOCATION;
        private String formLocation = Constants.FORM_LOCATION;Thanks

  • Need help - method call error cannot resolve symbol

    My code compiles fine but I continue to receive a method call error "cannot resolve symbol - variable superman" - can't figure out why. Here is my code:
    public static String caesar(String message, int shift)
    {   [b]String result = "";
    for(int i = 0; i < message.length(); ++i)
    {   [b]char newChar = message.charAt(i + shift);
    result += newChar;
    return result.toUpperCase();
    I entered "superman" for message and "3" for the shift. Can someone please help? Thanks!

    Your post worked great - especially since it made me realize I was going about it all wrong! I was attempting to convert "superman" to "vxshupdq" - basically a cipher shift starting at index 0 and shifting it 3 character values which would result in s changing to v. I restructured my code:
    public static String caesar(String message, int shift)
    {   [b]String result = "";
    for(int i = 0; i < message.length(); ++i)
    {   [b]char newChar = message.charAt(i);
    result += (newChar + shift) % message.length();
    return result.toUpperCase();
    But it's displaying the result as a "60305041". How can I get it to display the actual characters?

  • ToArray error: cannot resolve symbol

    Hi ther,
    I am getting errors on the line:
    newArray = (char[]) newArrayList.toArray(new char[newArrayList.size()]);
    I am getting the following error:
    vowelProcess.java:176: cannot resolve sybmol
    Symbol : method toArray (char[])
    Location : class java.util.ArrayList
    I cant see what I am doing wrong. I have also tried the following:
    newArray = newArrayList.toCharArray();
    But get a similar error. Here is the entire method:
    public static void getDistinctVowels(char[] vowelArray)
    String newArrayValues; //initialise the option entered by user
    List newArrayList = new ArrayList();
    char[] newArray;
    boolean aValue = false;
    boolean eValue = false;
    boolean iValue = false;
    boolean oValue = false;
    boolean uValue = false;
    for(int i=0; i < vowelArray.length; i++){
         if (vowelArray[i] == 'a')
              aValue = true;
         if (vowelArray[i] == 'e')
              eValue = true;
         if (vowelArray[i] == 'i')
              iValue = true;
         if (vowelArray[i] == 'o')
              oValue = true;
         if (vowelArray[i] == 'u')
              uValue = true;
         } // end of for
    if (aValue == true)
              newArrayList.add(new char['a']);
    if (eValue == true)
              newArrayList.add(new char['e']);
    if (iValue == true)
              newArrayList.add(new char['i']);
    if (oValue == true)
              newArrayList.add(new char['o']);
    if (uValue == true)
              newArrayList.add(new char['u']);
    if (newArrayList.size() > 0)
              newArray = (char[])newArrayList.toArray(new char[newArrayList.size()]);
         String contentsOfNewArray = "";
         for(int i=0; i < newArray.length; i++) {
              contentsOfNewArray = contentsOfNewArray + newArray;
         } // end of for
    System.out.print("The contents of the new array are: " + contentsOfNewArray);
         else
              System.out.print("No values were entered.");
    } //getDistinctVowels
    } //vowelProcess

    one more question on this:
    If I loop through this array and print out the contents, I do not get the character value (should be a,e,i or u) but some other interpretation: "[C@6b97fd" instead of "a"
    here is the code:
    char[][] newArray = (char[][]) newArrayList.toArray(new char[newArrayList.size()][1]);
    System.out.println("The contents of the new array are: ");
         for(int i=0; i < newArray.length; i++) {
              System.out.println("Test: " + (char[])newArray);
         } // end of for
    I have also tried:
    System.out.println("Test: " + newArray[i]);
    or
    System.out.println("Test: " + newArray[i][0]);
    or
    System.out.println("Test: " + newArray[i][1]);
    thanks again.

  • Compiler error: "cannot find symbol" - constructor

    Dear all,
    I keep getting the compiler error "cannot find symbol" - constructor AWTEvent() for the following class. It's supposed to extend AWTEvent to give me my own event to be fired. What could be wrong?
    import java.awt.*;
    import java.awt.event.*;
    public class MyButtonEvent extends AWTEvent
         public MyButtonEvent()
    }Thanks a lot!
    N

    When you do this
    public MyButtonEvent()
    }you are implicitly calling the super class constructor with no parameters
    That is:
    AWTEvent();
    you can think of it as
    public MyButtonEvent()
         AWTEvent(); // <-- automatically generated for you
         //the rest of your stuff
    }the problem is that AWTEvent has no such constructor, so you need to explicitly put another constructor in your constructor as the first statement. This other constructor has to be one that exists in AWTEvent.

  • WebHelp Template Error: cannot resolve macro

    RoboHelp HTML 5.0.2 Build 801
    Word 2003 SP3
    I have been working fine until this afternoon. I tried to
    generate webhelp in two different projects. In the output window I
    see messages through Updating files, and then a message flashes and
    it goes to done, but nothign is there to view.
    The message is something like Template Error: cannot resolve
    macro WHH#78 or something like that. I really cannot read it.
    I have look for the answer on this forum and in the Help
    system, to no avail. I will be leaving soon but will come in the
    morning and try to start troubleshooting again. Any ideas that
    might help would be greatly appreciated
    sandy

    Thanks for your time.
    I am using RoboHelp HTML 5.0.2 Build 801
    I have created 5 or 6 help files. I always open them with
    RoboHelp HTML because the primary layout is web help to be
    published to the web.
    I always use the Single Source Layouts in the Project tab to
    generate Printed Documents. I usually use the generate primary
    layout for the web help.
    This is the exact error I get, no matter which of my projects
    I try to generate web help for:
    Template Error: can not resolve macro: WH_CSH2_HTM
    Finished compiling WebHelp in 6 sec(s)
    Should I reinstall WebHelp to fix the corrupted template? If
    so will I have to restore my default.css?
    I am a really plain bread and butter user. I have not
    imported any templates or customized any templates. I have always
    just opened my projects with ROBOhelp HTML and generated.
    (Successfully, I might add, up until now).
    Thanks again for any help you can give me.
    Sandy

  • [stupid]error: cannot resolve "libusb1", a dependency of "libdc1394"

    Hi!
    :: Starting full system upgrade...
    resolving dependencies...
    error: cannot resolve "libusb1", a dependency of "libdc1394"
    error: failed to prepare transaction (could not satisfy dependencies)
    :: libdc1394: requires libusb1
    I needed libdc1394 only for gstreamer-plugins-bad, so I removed those. Wanted to try out if I need them anyway. But... What if? Is this a bug, did I do something wrong or did I just update while the required version isn't up yet and should unset testing again?
    EDIT: Uh, sorry, yes, I guess that's just me not waiting for the files to be distributed to the servers I guess.
    EDIT2: At least looks like it, should wait & think instead of type and type. Me drinking to much coffee. Marking thread as "stupid" instead of "solved" now.
    Last edited by whoops (2009-05-03 23:18:02)

    I do not thing archbang is officially  archlinux distributions (you are on an archlinux forum). This error does not appear on the current archlinux distribution. My guess is that here is a confusion between python / python2 / python3. Just run pacman -Si to know (or the equivalent of pacman for archbang).
    I would suggest you to use the official archlinux instead of this fork, archlinux has much more support and users and I do not quite understand what archbang has to offer: Their homepage said that it is archlinux combined with openbox, but you can just do
    pacman -S openbox
    on arch; it does not seems to justify a fork (but please correct me if I am wrong).
    Last edited by olive (2012-06-17 22:00:23)

  • Error: cannot resolve dependencies for "codecs"

    I receive this error when I'm trying to upgrade codecs 20060501-2 package. It tries to find libstdc++5 which is in Testing repository, and I'm not using Testing.
    error: cannot resolve dependencies for "codecs":
    "libstdc++5" is not in the package set
    I think libstdc++5 should be moved to Current or something like that (You know what to do )...
    Best regards

    Skyscraper wrote:
    I receive this error when I'm trying to upgrade codecs 20060501-2 package. It tries to find libstdc++5 which is in Testing repository, and I'm not using Testing.
    error: cannot resolve dependencies for "codecs":
    "libstdc++5" is not in the package set
    I think libstdc++5 should be moved to Current or something like that (You know what to do )...
    Best regards
    They are in testing repository:
    http://archlinux.org/packages.php?s_rep … ate=&pp=50

Maybe you are looking for

  • Nano doesn't work and itunes in restore/recovery mode loop

    My ipod nano 1st gen was fine (XP pro) - and then I plugged it in and it says "Itunes has detected an Ipod in rocover mode. You must restore this ipod before it can be used in windows." I press restore and it seems to be restoring - and says its rest

  • Anyone else having problems with group messages in iOS 7?

    Upgrade to iOS7 went fine. Everything worked smoothly up until about 6:30pm Central time. Can't send/receive group messages in iMessage. Anyone else? Not sure if this is a problem with my phone or iMessage.

  • I am getting weird and strange language emails from Adobe, why?

    I receive e-mails from adobe in a language I can not understand. Why do I get e-mails in Chinese?? I dont speak Chinese. Unless Adobe tells me that those e-mails are not from Adobe, See Image.

  • Phone sends mulitiple duplicate SMS text messages

     For about the last week I have had several recipients of text messages from me that complain they are getting the same message from me over and over, usually it seems to happen in three's. My phone is the HTC Thuderbolt.

  • How much time does the ESS import take?

    Hi, How much time does import of ESS into NWDI take? I have selected following files for import yesterday: SAP-JEE SAP-BUILDT SAP-ESS SAP-JTECHS SAPPCUI_GP and looked at it today and it is still importing. In CMS Transport Studio State column display