LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Java 1.5 (https://www.linuxquestions.org/questions/linux-software-2/java-1-5-a-641612/)

nano2 05-12-2008 05:55 AM

Java 1.5
 
Hi ,

I am using the following java disto
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux
but am getting the following errror message at runtime
Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in acc.jar file:/usr/share/java/libgcj-3.4.6.jar, file:./, core:/

Now when i look in libgcj-3.4.6.jar the StringBuilder class is not found .

Does anyone know where I can locate this or is the StringBuilder functions not in this version of Java ..

Any suggestions much appreciated .
Thanks

indienick 05-12-2008 09:36 AM

I apologize for this not being much help, but GCJ makes my toes curl - it's nice that it compiles Java to a native Linux binary, but aside from that, it really serves no other purpose that to frustrate Java programmers. I ran into this problem so many times (and never found a solution) where I would write a quick program, compile it without any errors, and then it would refuse to run with a bullsh*t error, like that one.

Are you making a call to the StringBuilder class in your program, or do you have anything like
Code:

String s = "hello " + "world";
in your code?

nano2 05-13-2008 03:39 AM

Yes, I am calling the StringBuilder class ..

jlliagre 05-13-2008 05:29 AM

Is there a specific reason for you not to use Sun JVM ?

indienick 05-13-2008 08:15 AM

Hmm...as a proposed solution, I read up on the java.lang.StringBuilder class, and it appears to just be used for building Strings out of other various types.

Try this, perhaps (depending on your needed usage)?:
Code:

...
  String s = "";

  s += Integer.toString(someInt);
  s += Boolean.toString(someBoolean);
...

Essentially, just using the class versions of the basic types to convert the values to a String. :)

jlliagre 05-13-2008 09:29 AM

StringBuilder purpose is not to provide these append methods as they already existed in the older StringBuffer class.
Your sample code is using StringBuffer under the hood.
StringBuilder purpose is to boost performance when the string isn't used by more than one thread, a common situation.

indienick 05-13-2008 09:47 AM

Ah - okay. Thanks for that jlliagre. :)

I just looked at the GCJ site, and there is no 3.4.6 release - it may have just been a minor, bugfix release. If I may suggest upgrading to GCJ 4.3.0.

How are you compiling, and trying to run the particular program?


All times are GMT -5. The time now is 05:09 AM.