dhanuP
dhanuP

Reputation: 31

How to redirect jar output from ubuntu command prompt to text file

I created jar file and I run it using command as follows:

$ java -jar niidle.jar arguments...

it is showing correct output. But I cant see the whole output. I want to see the whole output. so how to redirect this whole thing to text file, when I run following command:

$ java -jar niidle.jar arguments...

Upvotes: 3

Views: 7554

Answers (4)

Soheil Pourbafrani
Soheil Pourbafrani

Reputation: 3427

To save error logs in a file and normal console logs in another file:

java -jar niidle.jar arguments 2> errorOutput.log > output.log

Upvotes: 1

N Deepak Prasath
N Deepak Prasath

Reputation: 385

This should do !!

java -jar class.jar 2>> log.txt

Upvotes: 3

andcoz
andcoz

Reputation: 2232

If you do not need to save the output for future reference, you can read the full output this way:

java -jar niidle.jar arguments | less

Obviously, we are supposing that there is no user interaction. Otherwise you can do something like the following example to save the output and review it later.

java -jar niidle.jar arguments | tee output
... some user interaction ...
less output

Upvotes: 0

Raghuram
Raghuram

Reputation: 52645

jar -jar niidle.jar arguments > output

Upvotes: 3

Related Questions