0

I have my project which was compiled and built using jdk1.4. Now I want to compile the same with jdk1.8.

However, build fails saying that StringBuilder is not found in java.lang package which is strange for me. In my build.xml file, I have set source=1.4 & target = 1.8. Am I doing anything wrong?

StringBuilder was introduced in jdk1.5 and our legacy project is getting compiled with 1.4. There are lines of code similar to the below sample.

throw new IllegalArgumentException("usage of String Builder ("+data.length+")");

I have 2 doubts here:

  1. How is the code getting built with jdk1.4? In the build.xml,I specified source and target versions to 1.4 and it builds fine.
  2. Why is not getting build for any versions(source and target) higher than 1.4?
Rao
  • 20,781
  • 11
  • 57
  • 77
Vignesh
  • 259
  • 4
  • 15
  • 2
    As per javadocs StringBuilder Since: 1.5 – Scary Wombat Feb 18 '16 at 02:48
  • 1
    Have you modified your code since you last compiled it on 1.4? If it compiled in 1.4, it shouldn't have `StringBuilder` in it. – shoover Feb 18 '16 at 03:13
  • 1
    Possible duplicate of [what's the difference between -source and -target compatibility?](http://stackoverflow.com/questions/10663450/whats-the-difference-between-source-and-target-compatibility) – shoover Feb 18 '16 at 03:13
  • @shoover: The code is not modified. I have added more explanation on what I have done so far. Please check. Sorry for not giving up full info upfront. – Vignesh Feb 18 '16 at 04:08
  • 1
    Does your program also contain a `class StringBuilder`? If so, there may be naming conflicts and you'll have to use the full package name. – Elliott Frisch Feb 18 '16 at 04:17
  • @ElliottFrisch:No such class in the project – Vignesh Feb 18 '16 at 05:40

0 Answers0