saving Jpeg to a specified location (linux)
saving Jpeg to a specified location (linux)
Hello,
I am currently trying to save the jpeg that is created using
ChartUtilities.saveChartAsJPEG into a specified location on my
harddrive. I have tried prepending the the jpg file with a path like:
ChartUtilities.saveChartAsJPEG(new File("images/" + Fname + Lname + Cycle + dateFormat + ".jpg"), chart, 650, 450); //width height
after doing this my application does not function properly and returns a null. I cant seem to save these files where I would like them to be saved. I would be very appreciative of the responses. Thanks!
r,
TT
I am currently trying to save the jpeg that is created using
ChartUtilities.saveChartAsJPEG into a specified location on my
harddrive. I have tried prepending the the jpg file with a path like:
ChartUtilities.saveChartAsJPEG(new File("images/" + Fname + Lname + Cycle + dateFormat + ".jpg"), chart, 650, 450); //width height
after doing this my application does not function properly and returns a null. I cant seem to save these files where I would like them to be saved. I would be very appreciative of the responses. Thanks!
r,
TT
Last edited by Tan T on Tue Feb 10, 2004 10:43 pm, edited 2 times in total.
-
- Posts: 22
- Joined: Thu Jan 29, 2004 8:28 pm
Hello,
I am not sure what you are referring too??? I am logged on as root on my machine I have rights to all files and directories.
Currently the jpg files are being created in:
/var/tomcat4
I want the jpg files to be created in:
/var/tomcat/webapps/Assignment1/jsp/images
After saving them into the images folder, I can than use the jpg images and call them from my JSP page.
r,
T Tran
I am not sure what you are referring too??? I am logged on as root on my machine I have rights to all files and directories.
Currently the jpg files are being created in:
/var/tomcat4
I want the jpg files to be created in:
/var/tomcat/webapps/Assignment1/jsp/images
After saving them into the images folder, I can than use the jpg images and call them from my JSP page.
r,
T Tran
Below is my code, I figured out how to save the jpgs to the windows file system, when I use the windows file system format it works using the code below
String path = "C:/Oracle/jdev/mywork/Application1/Project1/public_html/images/";
try {
ChartUtilities.saveChartAsJPEG(new File(path + Fname + Lname + Cycle + dateFormat + ".jpg"), chart, 650, 450); //width height
returnCode = Fname + Lname + Cycle + dateFormat + ".jpg";
}
catch (java.io.IOException e) {}
}
When saving my project and loading all files onto the linux box I use the linux file system format and the jpgs is not created and I get a NULL
String path = "/var/tomcat4/webapps/Application1/jsp/images";
try {
ChartUtilities.saveChartAsJPEG(new File(path + Fname + Lname + Cycle + dateFormat + ".jpg"), chart, 650, 450); //width height
returnCode = Fname + Lname + Cycle + dateFormat + ".jpg";
}
catch (java.io.IOException e) {}
}
Not sure if I am using the correct format in linux, any help appreciated
Thanks!
String path = "C:/Oracle/jdev/mywork/Application1/Project1/public_html/images/";
try {
ChartUtilities.saveChartAsJPEG(new File(path + Fname + Lname + Cycle + dateFormat + ".jpg"), chart, 650, 450); //width height
returnCode = Fname + Lname + Cycle + dateFormat + ".jpg";
}
catch (java.io.IOException e) {}
}
When saving my project and loading all files onto the linux box I use the linux file system format and the jpgs is not created and I get a NULL
String path = "/var/tomcat4/webapps/Application1/jsp/images";
try {
ChartUtilities.saveChartAsJPEG(new File(path + Fname + Lname + Cycle + dateFormat + ".jpg"), chart, 650, 450); //width height
returnCode = Fname + Lname + Cycle + dateFormat + ".jpg";
}
catch (java.io.IOException e) {}
}
Not sure if I am using the correct format in linux, any help appreciated
Thanks!
Hi,
well, most systems do not run the tomcat server as user "root" for security reasons. So it could be still a permission issue. But you will never know, as you swallow the exception, without printing any log information.
Right now, your system silently smiles while you try to find the bug ... Please: Don't ignore exceptions - they all carry a message which might be important for you
Have more fun,
said Thomas
well, most systems do not run the tomcat server as user "root" for security reasons. So it could be still a permission issue. But you will never know, as you swallow the exception, without printing any log information.
Right now, your system silently smiles while you try to find the bug ... Please: Don't ignore exceptions - they all carry a message which might be important for you

Have more fun,
said Thomas
How can this be accomplished in using linux path to specifying where I want to save my jpg files?
In windows I use: C:/Oracle/jdev/mywork/Application1/Project1/public_html/images/
and it works
In linux I have some jpgs already located in the images directory, but when I creat new jpgs in my application the jpgs does not go to the path that I specified.
Thanks!
(Sorry don't mean to beat a dead horse!)
In windows I use: C:/Oracle/jdev/mywork/Application1/Project1/public_html/images/
and it works
In linux I have some jpgs already located in the images directory, but when I creat new jpgs in my application the jpgs does not go to the path that I specified.
Thanks!
(Sorry don't mean to beat a dead horse!)

Hi,
well, here comes my question: Have you checked, which exception (if any, but I guess there is one) is caught?
Please add a "e.printStackTrace()" into your "try/catch" block, or you won't see if anything goes wrong, and playing guessing games with the computer is borring - the maschine will never get bored
The stacktrace of that exeption would be nice too ... as it carries the hints which lead to the cause of all the trouble.
Btw. There is a trailing slash missing in your path, so that the created file might be incorrect. But you will never know without looking at the exception
Have more fun,
said Thomas
well, here comes my question: Have you checked, which exception (if any, but I guess there is one) is caught?
Please add a "e.printStackTrace()" into your "try/catch" block, or you won't see if anything goes wrong, and playing guessing games with the computer is borring - the maschine will never get bored

The stacktrace of that exeption would be nice too ... as it carries the hints which lead to the cause of all the trouble.
Btw. There is a trailing slash missing in your path, so that the created file might be incorrect. But you will never know without looking at the exception

Have more fun,
said Thomas
Hello,
The following is the error I get when I print the error out:
Errorjava.io.FileNotFoundException:
/var/tomcat4/webapps/Application1/jsp/images/02112004.png (No such file or directory)
HERE IS HOW I USE THE PATH IN MY CODE:
String linuxpath = "/var/tomcat4/webapps/Application1/jsp/images/"
ChartUtilities.saveChartAsPNG(new File(linuxpath + Fname + Lname + Cycle + dateFormat + ".png"), chart, 650, 450); //width height
What do you think??
The following is the error I get when I print the error out:
Errorjava.io.FileNotFoundException:
/var/tomcat4/webapps/Application1/jsp/images/02112004.png (No such file or directory)
HERE IS HOW I USE THE PATH IN MY CODE:
String linuxpath = "/var/tomcat4/webapps/Application1/jsp/images/"
ChartUtilities.saveChartAsPNG(new File(linuxpath + Fname + Lname + Cycle + dateFormat + ".png"), chart, 650, 450); //width height
What do you think??
This probably means one of the parent directories in your path there does not exist...
I'm guessing that images dir in /var/tomcat4/webapps/Application1/jsp probably doesn't already exist when you call new File(...).
Make sure that all your parent directories exist, or use the
mkdirs() method that is in the File class. to make the parent directories
before you call the saveChartAsPNG method.
You can try something like this:
File dirs = new File(/var/tomcat4/webapps/Application1/jsp/images);
if (! dirs.exists()) {
dirs.mkdirs();
}
Oh and you should never ignore expections completely, they are there for a reason.
Jeff
I'm guessing that images dir in /var/tomcat4/webapps/Application1/jsp probably doesn't already exist when you call new File(...).
Make sure that all your parent directories exist, or use the
mkdirs() method that is in the File class. to make the parent directories
before you call the saveChartAsPNG method.
You can try something like this:
File dirs = new File(/var/tomcat4/webapps/Application1/jsp/images);
if (! dirs.exists()) {
dirs.mkdirs();
}
Oh and you should never ignore expections completely, they are there for a reason.
Jeff
writing files in linux
hi,
I encountered a similar problem and I just created an empty file :
then changed permissions on that file
(if that works, change it to 755 or something more sane)
Now you should be able to write. A better solution would be to change permissions on the whole dir, so non-root users can write in that dir.
Mike
I encountered a similar problem and I just created an empty file :
Code: Select all
touch myfile.png
Code: Select all
chmod 777 myfile.png
Now you should be able to write. A better solution would be to change permissions on the whole dir, so non-root users can write in that dir.
Mike