0

I am trying to run a small batch file with the following lines to print the output of java version.

@echo off
set instDir=%cd%
set JAVA_DIR="%instDir%\bin\jre\bin\java.exe"
%JAVA_DIR% -version > output.txt

When I run (double click) this file with "*.bat" extension, nothing is written to the output.txt.

When I execute the same file from command prompt, it prints the version on command prompt, but does not print to the file.

1

1 Answer 1

0

You are trying to redirect the standard output but you need to redirect the error output:

@echo off
set instDir=%cd%
set JAVA_DIR="%instDir%\bin\jre\bin\java.exe"
%JAVA_DIR% -version 2> ".\output.txt"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.