Hi Thanks All for the replies
After long search and checking , I have found the exact Problem .
By the way i was using openjdk I was getting the the null pointer exception (jpegEncoder was null) but i have tested the same code using sun jkd and it works fine .
the got the tip from :
OpenJDK does not have a native JPEG encoder, try using Sun's JDK, or using a library (such as JAI
AFAIK, regarding the "pinkish tint", Java saves the JPEG as ARGB (still with transparency information). Most viewers, when opening, assume the four channels must correspond to a CMYK (not ARGB) as thus the red tint.
If you import the image back to Java, the transparency is still there, though.
from the
link
my question now is How to implement that using jai so that i could run it using openjdk