By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,645 Members | 1,328 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,645 IT Pros & Developers. It's quick & easy.

File created from eclipse but not from running jar

P: 79
Hi ,
I have developed a java code to read csv file and write another file after some modifications, the code is working fine when running through eclipse, but when I am creating jar and trying to execute it the files are not getting created.
Any idea why it is happening.
I am using windows 7.
Feb 29 '12 #1
Share this Question
Share on Google+
12 Replies

P: 13,264
How are you executing the jars and where are the files supposed to be created?
Mar 1 '12 #2

P: 79
I am executing the jar using command prompt in widows
Expand|Select|Wrap|Line Numbers
  1. java -jar xxx.jar
the log file is also getting generated where I have printed the message that files are written.
Mar 1 '12 #3

P: 79
the files are supposed to be created in a new folder in the same system.
Mar 1 '12 #4

P: 13,264
Does the log file say that the files have been created?
How do you specify the output folder for the files?
Mar 1 '12 #5

P: 79
yes the log file is saying file is created, i have specified the ouput folder in a properties file , the code is running fine from eclipse IDE.
Mar 1 '12 #6

P: 13,264
Let's see the code where you get the output file path from the properties and create File/FileWriter object with it.
Mar 1 '12 #7

P: 79
Expand|Select|Wrap|Line Numbers
  1.     String filename= properties.getProperty("out");
  3. Writer output = new BufferedWriter(new FileWriputfileter(filename));
  4. output.write(strbuff.toString());
  6.                     output.flush();
  7.                     output.close();
Mar 1 '12 #8

P: 13,264
Do you have e.printStackTrace() in your catch block?
It could be that your property file was not found/loaded in the jar file and an exception is being thrown?
Mar 1 '12 #9

P: 79
tested the jar in other system with windows 7 and it is working only in my system it is not creating file. No exception is thrown i have e.getMessage() in the logs.
Mar 1 '12 #10

P: 13,264
What is the file output path specified like? Does it exist on your computer and do you have write rights to it?
Also if the the code is not too long you could post it here.
Mar 1 '12 #11

P: 79
code is too long, can't paste it here the output path is in my system only, C:/abhi/ff/. I have rights on it and able to create file in it when I am executing the code from eclipse... the log file is getting generated in both the cases while executing from eclipse and jar and all the log messages are same , but in case of jar the files are not getting created.
Mar 1 '12 #12

P: 13,264
If you are not hiding exceptions with an empty catch block then some condition that requires file to be generated is not being met on your computer. Also try executing the jar as an administrator.
Mar 1 '12 #13

Post your reply

Sign in to post your reply or Sign up for a free account.