开发者

How do I find out which version of Java I am using Perl?

开发者 https://www.devze.com 2022-12-29 15:28 出处:网络
How do I find out which version of Java I am using Perl programming and using that execute some jar开发者_开发知识库 file based on that?You can capture the Java version from a Perl script using backti

How do I find out which version of Java I am using Perl programming and using that execute some jar开发者_开发知识库 file based on that?


You can capture the Java version from a Perl script using backticks.

$version = `java -version`;

Also see: How can I capture STDERR from an external command? for more alternatives than you can shake a stick at.


in a perl script,

@args = ("java", "-version");
system(@args) == 0
    or die "system @args failed: $?"

or rather simply,

system("java -version");


use IO::Handle;

open OUTPUT, '>', "output.txt" or die $!;
STDERR->fdopen( \*OUTPUT, 'w' ) or die $!;

print `java -version`;


"java -version" will show you the version you are using.

"perl -v" will show you the version of Perl you are using.


Use the System command...

system("java -version");

If you are going to export a new Java

system('export PATH=/usr/java1.6/bin:$PATH');
0

精彩评论

暂无评论...
验证码 换一张
取 消