them in memory sequentially(pic0.jpg,pic1.jpg....etc).Simultaneously
I'm accessing the saved files from another
independent application(Prog name:- Test_Main.java) through
piping(executing the application like this "Java
Test_ScreenShot|Java Test_Main").The application is in infinite
loop.I'm using Version JDK 1.5
I use java ImageIO to read and write image:-
My application was running well for days.But now I'm getting sudden
exceptions.
I got an excepton while trying to save an dynamically generated image
file in the local memory using the ImageIO
class.In brief I'm getting exactly 3 types of exceptions:-
1)java.io.FileNotFoundException: pic5.jpg (Access is denied)
2)"Exception in thread "main" java.lang.NullPointerException
3)Exception in thread "main"
com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts
with 0xff 0xd9
Here is the code snippent I wrote:
/* Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRect);
// save captured image to jpg file
ImageIO.write(image, "jpg", new File(outFileName));*/
And here is the exception I am finding (I never found this before, I
executed the code many times )
=====================================================================================================================
1)Exception Type 1:-
java.io.FileNotFoundException: pic5.jpg (Access is denied)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
at
javax.imageio.stream.FileImageOutputStream.<init>(FileImageOutputStream.java:44)
at
com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(FileImageOutputStreamSpi.java:37)
at
javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:391)
at javax.imageio.ImageIO.write(ImageIO.java:1483)
at Test_ScreenShot.main(Test_ScreenShot.java:112)
at Test_Main.main(Test_Main.java:466)
at Test_ScreenShot.main(Test_ScreenShot.java:129)
2)Exception Type 2:-
"Exception in thread "main" java.lang.NullPointerException
at Picture.width(Picture.java:84)
at Test_Edge_Detector.not_main(Test_Edge_Detector.java:38)
at Test_Main.main(Test_Main.java:88)"
============================================================================================
Now I tried the following as alternative of ImageIO(from jdk 1.2)
to read image:-
FileInputStream fis = new FileInputStream(file);
JPEGImageDecoder jpeg = JPEGCodec.createJPEGDecoder(fis);
jpeg.decodeAsBufferedImage();
fis.close();
But after running a long time suddenly its giving following
exceptions:-
==============================================================================================
Exception Type 3:- )
Exception in thread "main"
com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts
with 0xff 0xd9
at
sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGStream(Native Method)
at
sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsBufferedImage(Unknown
Source)
Exception Type 4:- )
javax.imageio.IIOException: Not a JPEG file: starts with 0xff 0xd9
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native
Method)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(Unknown
Source)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(Unknown
Source)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(Unknown Source)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(Unknown Source)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown
Source)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Unknown
Source)
at javax.imageio.ImageIO.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at Picture.<init>(Picture.java:22)
at Test_Edge_Detector.not_main(Test_Edge_Detector.java:37)
at Test_Main.main(Test_Main.java:88)
Exception in thread "main" java.lang.RuntimeException: Could not open
file: pic45.jpg
at Picture.<init>(Picture.java:27)
at Test_Edge_Detector.not_main(Test_Edge_Detector.java:37)
at Test_Main.main(Test_Main.java:88)
My question is:-
1)Where is the actual problem?Is it any kind of bug?
2)I'm using the concept of piping recently to execute the
application.Can it be the cause?
When I googled I found the following informations.There is a bug in
ImageIO while trying to write image file.But
I'm not sure about that it will be relevent here :-
1)from sun's bug database:-
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6247985
2)from SUN Developer Forums
http://forum.java.sun.com/thread.jspa?threadID=768917&messageID=4382833
3)from Java.NET forum(here they r getting the bug while they r using
createScreenCapture() method of robot class,I am
also using that in my code)
http://forums.java.net/jive/thread.jspa?messageID=123247
4)from SUN's archieve
http://archives.java.sun.com/cgi-bin/wa?A2=ind0207&L=java-imageio-interest&D=0&P=1483
5)Here is the actual implemetation of ImageIO class.I'm getting error
at 391 no. line.
http://kickjava.com/src/javax/imageio/ImageIO.java.htm
Thanks And Regards
Subhadip
This statement doesn't make much sense (well, most of what you write
doesn't make much sense to me ...).
Above you claim you write the data to memory, while at the same time you
claim you write it to a file, or to several files. What is it what you
are doing?
> independent application(Prog name:- Test_Main.java) through
> piping(executing the application like this "Java
>
> Test_ScreenShot|Java Test_Main").The application is in infinite
> loop.I'm using Version JDK 1.5
And here you claim variant number three, writing the data to standard
out. Again, what is it what you are really doing?
> I use java ImageIO to read and write image:-
> My application was running well for days.But now I'm getting sudden
> exceptions.
So something changed. The code or the environment. So what did recently
change?
> I got an excepton while trying to save an dynamically generated image
> file in the local memory using the ImageIO
>
> class.In brief I'm getting exactly 3 types of exceptions:-
Well, in general it seems as if you where sloppy in implementing your
tools, and don't handle exceptions well. I would guess the first one is
the real problem, the others are there, because you didn't handle the
first exception correctly.
> 1)java.io.FileNotFoundException: pic5.jpg (Access is denied)
That one means what it says. Check if you have the necessary rights.
> /* Robot robot = new Robot();
> BufferedImage image = robot.createScreenCapture(screenRect);
> // save captured image to jpg file
> ImageIO.write(image, "jpg", new File(outFileName));*/
And we now have to guess how you do your exception handling? Well, I
have enough, maybe others can guess more.
/Thomas
--
The comp.lang.java.gui FAQ:
http://gd.tuwien.ac.at/faqs/faqs-hierarchy/comp/comp.lang.java.gui/
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
Are doing?
]
I never used the term "Data".I used the term "image files". I save
the generated "image files" in memory. I never wrote that I write it to
"a" file.
I just told, I am sequentially creating image files by taking
screenshot
And saving them in memory sequentially u knows that "file always stay
at memory"?
[And here you claim variant number three, writing the data to standard
Out. Again, what is it what you are really doing?
]
Can't any application produce both data and image? Every java
application needs to execute first using java command. I am executing
the program like Test_ScreenShot|Java Test_Main.When the application
is running image files are generated and saved and some calculation is
taking place in the background. The calculated data may be written in
standard out, but image files are saved in memory.
[So something changed. The code or the environment. So what did
recently?
Change?]
I never wrote that any code or environment changed. The change is that
I am getting exception suddenly. Another thing I mentioned that
recently I used the concept of piping to run the application. No code
or environment change.
> [And we now have to guess how you do your exception handling? Well, I
> have enough, maybe others can guess more.]
"Code snippet" does not mean the total code. Of course the exception
handling is there.
If there is security restriction why I'm not getting exception every
time?
Say the code is running well 100 times but at 101 times it gives a
sudden exception. I did not find any similarities about when the
exceptions are generated. It's random.
Thomas I don't think u'll never understand the case,and always ask
"What is it what you
Are doing?". while many pepole have already understood the actual
problem and I'm discussing with them.
Don't worry the problem will be solved quickly with the people who can
understand it.
Since this is one of the few posts of the multitude
of multi-posts that you are apparrently *reading*,
I will take the opportunity to say..
*stop* *multi*-*posting*.
Andrew T.
Since you have decided to start redefining terms and totally miss the
point that clarifying your question might benefit you, I consider you a
hopeless case.
> If there is security restriction why I'm not getting exception every
> time?
Are you asking me? Don't you state below that I shouldn't pay attention
to your questions any more?
> many pepole have already understood the actual
> problem and I'm discussing with them.
Oh sure, I see hordes of people in the 9+ groups you multiposted to for
a few days now - not. Actually, I don't see anyone else having a look at
the technical details.
> Don't worry the problem will be solved quickly with the people who can
> understand it.
Don't listen to the voices in your head.
Oh no, that list* was as of 10 minutes ago!
>...now - not. Actually, I don't see anyone else having a look at
> the technical details.
Maybe the OP is referring to these..
* <http://forum.java.sun.com/profile.jspa?userID=665653> ?
Andrew T.
.
I am helping others, not to waste theirs.
(This is not about you)
> ....But I'm sure you will berk again because "Everything
> has a limit, but stupidity".
..and multi-posting, apparently. But that works,
because the two go well together, in any case.
Be seein' you around - wherever you and
your voices end up. ;-)
Andrew T.