Page 1 of 2 12 LastLast
Results 1 to 20 of 23
  1. #1
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Unhappy Help with AbstractStringBuilder

    Hi, everybody

    I wrote a little programme but have faced a strange error I don't know how to solve it. When I try to compile my code a strange error appears look...

    "Loo.java": Error #: 311 : class java.lang.AbstractStringBuilder is not public, therefore method append(java.lang.CharSequence) cannot be accessed from outside package at line 562, column 89
    I know it is all about the AbstractStringBuilder is not public but haven't got a clue how can I still use its append() method :( I need it. Or if there is a way around the append() method to replace it with some... could you advice me the best way plz.

    The code which make the error is
    Java Code:
    (new StringBuilder()).append(System.getProperty("user.Loo")).append(File.separator).append(".loo").toString();
    Thanks

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    Java Code:
    (new StringBuilder()).append(System.getProperty("user.Loo")).append(File.separator).append(".loo").toString();
    i cannot find any error...
    can you give more detail?
    Last edited by mtyoung; 04-07-2009 at 03:37 AM.

  3. #3
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    Actually. there shouldn't be any error. It is all because I try to use a lib class out the lib. But if I take the class out the lib it is always the error about append() method appears. I don't know what to do??? Maybe there is a way I can adapt java.lang.AbstractStringBuilder to make it useful out the lib jar file?
    The class I want to take out the lib is KeyTool. class

    My major question is how can I use classes if I take them out a lib?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    what the heck do you mean, "take them out of a lib"???

  5. #5
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    Because the error as
    "Loo.java": Error #: 311 : class java.lang.AbstractStringBuilder is not public, therefore method append(java.lang.CharSequence) cannot be accessed from outside package at line 562, column 89
    is always appear if I want to compile a java file which is out a lib :(
    This append() method is always throws the error. How can I sovle it. Maybe there is a good replacement of the append() method or it is worth to make adaptation???

  6. #6
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    I mean a free source src lib JAR files. The src which is comes with the compiled one :)

  7. #7
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    you can only use AbstractStringBuilder within java.lang package...
    that means... your Class should place in java.lang package

    i wonder why you do not use StringBuilder?
    Last edited by mtyoung; 04-07-2009 at 05:01 AM.

  8. #8
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    I know the rule :) But is there any way I can use it in my project in my packages structure?
    Or if it is impossible as you saying show me what can I do to take out the KeyTool.java with no error with?

  9. #9
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    I have no idea how should I adapt the KeyTool.java to use it out the lib :(
    Actually that is the question...

  10. #10
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    The comment above says that
    This code is free software; you can redistribute it and/or modify it
    0006: * under the terms of the GNU General Public License version 2 only, as
    0007: * published by the Free Software Foundation.
    But I don't know how can I modify it and use it if there is always the java.lang.*; lib problem :(

  11. #11
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    i wonder why you do not use StringBuilder?
    That wasn't my choice the KeyTool.java uses the AbstractStringBuilder.
    Please advise me how can I use something else instead of the AbstractStringBuilder but that something should work the same.

  12. #12
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    here is the code... It's OK for it is free source... watch the attachment zip
    Attached Files Attached Files

  13. #13
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

  14. #14
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by mtyoung View Post
    the code fail to complie...
    I know that :(

    That's why I ask help. Is there any idea how to make it compile? The mini instruction says that the code can be used and modified but how? What should me do to succeed it's lib outer usage :)

  15. #15
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    what if I use, as mtyoung says, StringBuilder instead of AbstractStringBuilder?
    The question is how can I modify the code to avoid the range of errors?
    Any ideas?

  16. #16
    Join Date
    May 2010
    Posts
    1
    Rep Power
    0

    Unhappy AbstractStringBuilder

    i do have the similar problem of not recognizing the AbstractStringBuilder class

    my code

    StringBuffer sb = new StringBuffer();
    sb.append("xx");

    I am using java 1.4
    the append() method returns AbstractStringBuilder and this is not recognized at run time
    the error comes as this....

    [java.lang.StringBuffer: method append(Ljava/lang/String;)Ljava/lang/AbstractStringBuilder; not found]: java.lang.NoSuchMethodError: java.lang.StringBuffer: method append(Ljava/lang/String;)Ljava/lang/AbstractStringBuilder; not found

  17. #17
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by manishranjan.jha View Post
    i do have the similar problem of not recognizing the AbstractStringBuilder class

    my code

    StringBuffer sb = new StringBuffer();
    sb.append("xx");

    I am using java 1.4
    the append() method returns AbstractStringBuilder and this is not recognized at run time
    the error comes as this....

    [java.lang.StringBuffer: method append(Ljava/lang/String;)Ljava/lang/AbstractStringBuilder; not found]: java.lang.NoSuchMethodError: java.lang.StringBuffer: method append(Ljava/lang/String;)Ljava/lang/AbstractStringBuilder; not found
    The StringBuilder class didn't exist until Java 1.5. The StringBuffer class has always been with us. Don't fiddle with the AbstractStringBuilder class, it is not part of the published API.

    kind regards,

    Jos

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    What odd version of Java are you uising?
    Fromt he 1.4 docs, append(String) is a valid method of String Buffer.

    Moreover it has nothing at all to do with AbstractStringBuilder.

  19. #19
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Tolls View Post
    What odd version of Java are you uising?
    Fromt he 1.4 docs, append(String) is a valid method of String Buffer.

    Moreover it has nothing at all to do with AbstractStringBuilder.
    S/he wasn't talking about a StringBuffer (and old class), but about a StringBuilder (only saw the light at Java 1.5).

    kind regards,

    Jos

  20. #20
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    StringBuffer sb = new StringBuffer();
    sb.append("xx");

    ...

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •