5 Replies Latest reply: Sep 26, 2009 2:19 PM by 791266 RSS

    Running the Java Code from Batch File

    807580
      Hi All,

      I have run a code sucessfully in Eclipse and it uses Logging API from Java
      When i try running the same program from batch file it throws error

      java.io.IOException: Couldn't get lock for log\Properties_Log_16Sep2009_150229
      at java.util.logging.FileHandler.openFiles(Unknown Source)
      at java.util.logging.FileHandler.<init>(Unknown Source)
      at com.adidas.SPM.LogMessage.<init>(LogMessage.java:26)
      at com.adidas.SPM.MainApplication.initialize(MainApplication.java:51)
      at com.adidas.SPM.MainApplication.main(MainApplication.java:102)

      I am working on a windows systems the folder log has all the permission i have provided with all

      Not sure why the code runs like this

      The batch file is like below

      set CURR_DIR=%CD%
      cd %CURR_DIR%\bin
      %CURR_DIR%\jre6\bin\java -classpath .;%CURR_DIR%\lib\FirstProject.jar com.test.MainApplication
      echo %ERRORLEVEL% The Error Level
      echo SUCCESS
      GOTO END
      :END
      pause

      Rgds
      Aditya
        • 1. Re: Running the Java Code from Batch File
          807580
          I've not seen this syntax in a batch file before:
          "com.test.MainApplication"

          If you have an executable Jar, you should have something like:
          "java -jar myJarFile.jar"

          in your batch to launch it.
          • 2. Re: Running the Java Code from Batch File
            791266
            morgalr wrote:
            I've not seen this syntax in a batch file before:
            "com.test.MainApplication"
            Nothing wrong with that.
            • 3. Re: Running the Java Code from Batch File
              791266
              @Op. Check if you have any lock files in the directory, and remove them. Do also check so that you don't have multiple instances of the application running (depending how you define the log file name)
              • 4. Re: Running the Java Code from Batch File
                800580
                According to me the problem is that there are many instances trying to access the same property file. The best way to do is that create a schedular in Windows that runs at some predefined interval (say 1 minute).

                What will happen is if your program runs for more than a minute even then the new process will not start until old process is autaomatically killed. Please do not check this option if you want the program to exit normally.
                If the Task is still running stop at this time
                Thanks and Regards,
                Vikash Anand.
                • 5. Re: Running the Java Code from Batch File
                  791266
                  Vikash.SunJava wrote:
                  According to me the problem is that there are many instances trying to access the same property file.
                  Nothing wrong with that since they only are reading it.
                  The best way to do is that create a schedular in Windows that runs at some predefined interval (say 1 minute).
                  Huh?

                  >
                  What will happen is if your program runs for more than a minute even then the new process will not start until old process is autaomatically killed. Please do not check this option if you want the program to exit normally.
                  If the Task is still running stop at this time
                  O_o