Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:57:02+00:00 2026-05-27T06:57:02+00:00

I created a backup program. Program is running great but the logs are not

  • 0

I created a backup program. Program is running great but the logs are not generating. I am generating logs using three methods ,

System.out.println(message);

        try {

            if(logFileWriter != null){

                logFileWriter.write(message);
                logFileWriter.newLine();
                logFileWriter.flush();
            }

            Runtime.getRuntime().exec("echo " + message);

        } catch (IOException e1) {}

Log file initializer:

private static void initLog() { 
    File logFileObj = new File(logFile); 
    try { 
        FileWriter fileWriter = new FileWriter(logFileObj); 
        logFileWriter = new BufferedWriter(fileWriter); 
    } catch (IOException e) { 
        e.printStackTrace(); 
    } 
}

Here message is the message that I want to log. The file writer is initiated by the log file path given by the user at the run time using the command line argument.

When i am trying to run the program using the eclipse, logs are creating but when i run the executable jar file, no logs are creating. What can be the reason.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:57:02+00:00Added an answer on May 27, 2026 at 6:57 am

    Assumption: You are on Windows and you are creating this executable jar from Eclipse.

    Not sure how your complete code looks like this is what I did based on your code:

    package com.mumz.test.executable.jar;
    
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    
    public class JustPrint {    
        private static String         logFile   = "backooopLog.txt";
        private static BufferedWriter   logFileWriter;
        private static void initLog() {
                File logFileObj = new File(logFile);
            try {
                FileWriter fileWriter = new FileWriter(logFileObj);
                logFileWriter = new BufferedWriter(fileWriter);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            initLog();
            String message = "hello word";
            System.out.println(message);
            try {
                if (logFileWriter != null) {
                    logFileWriter.write(message);
                    logFileWriter.flush();
                }
                Runtime.getRuntime().exec("echo " + message);
            } catch (IOException e1) {
                e1.printStackTrace();
            } finally{
                try {
                    logFileWriter.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }    
    

    Then project->right click->export->Runnable Jar -> Select JustPrint in the launch configuration and give the file location – > Finish

    Then open command prompt browse where jar file was created, then type this command

    java -jar exectest.jar 
    

    (Considering Java path is set and I gave my jar name as exectest.jar, I can see log file being created in the same directory where jar file is located also, on my command prompt I can stacktrace while creating process.

    Now with this can you trace your code and see if you do something like this or different, post your findings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been writing a backup program using VSS and started out with VSHADOW.EXE from
I have a program that creates a notification if the application is not running.
Greetings.... I am writing a backup program in c# 3.5, using hte latest DotNetZip.
Hey, i've a simple question. Task: Program a backup system which can be used
I need a backup script but the executed program after executing asks Y or
I have a backup created of my mysql database (vbulletin forum v3.8) everyday. It's
I created a query that takes a database backup at certain specified location. I
I have created a shell script to backup my webfiles + database dump, put
I have an Oracle database backup file (.dmp) that was created with expdp .
I am using the RollingFileAppender and the Size rollingStyle. By default it creates backup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.