File created from eclipse but not from running jar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhishekbrave
    New Member
    • Dec 2007
    • 79

    File created from eclipse but not from running jar

    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.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    How are you executing the jars and where are the files supposed to be created?

    Comment

    • abhishekbrave
      New Member
      • Dec 2007
      • 79

      #3
      I am executing the jar using command prompt in widows
      Code:
      java -jar xxx.jar
      the log file is also getting generated where I have printed the message that files are written.

      Comment

      • abhishekbrave
        New Member
        • Dec 2007
        • 79

        #4
        the files are supposed to be created in a new folder in the same system.

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Does the log file say that the files have been created?
          How do you specify the output folder for the files?

          Comment

          • abhishekbrave
            New Member
            • Dec 2007
            • 79

            #6
            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.

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Let's see the code where you get the output file path from the properties and create File/FileWriter object with it.

              Comment

              • abhishekbrave
                New Member
                • Dec 2007
                • 79

                #8
                Code:
                	String filename= properties.getProperty("out");
                
                Writer output = new BufferedWriter(new FileWriputfileter(filename));
                output.write(strbuff.toString());
                
                					output.flush();
                					output.close();

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Do you have e.printStackTra ce() 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?

                  Comment

                  • abhishekbrave
                    New Member
                    • Dec 2007
                    • 79

                    #10
                    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.

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      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.

                      Comment

                      • abhishekbrave
                        New Member
                        • Dec 2007
                        • 79

                        #12
                        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.

                        Comment

                        • r035198x
                          MVP
                          • Sep 2006
                          • 13225

                          #13
                          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.

                          Comment

                          Working...