Detect if specific software is installed on a user's computer in Java

I have a Java application that requires certain software (one of which is Perl) before it starts. What I used to detect Perl:

Runtime.getRuntime().exec("perl Test.pl");

and if there was an IOException, declare that there was no Perl.

However, one of my users complained that the application was not working because it did not put Perl in its path. That's why I ask: is there any cross-operating system method for determining if Perl (or any other software) is installed in the user system and the path to the program?

+2
source share
4 answers

(), (FileChooserDialog), ( ). , , , SysAdmins, , , ( , ).

, , , .

+1

, , () . , Java , ; , , . , , -Java- /, " ".

, / JNI, - , , "". , , , - Perl, perljvm .

+6

  • perl
  • , perl, , , Windows ..

, - Perl. , , - ,

+3

Windows java SDK API. API ( LGPL ), , .

1 - (perl)

, , ProcessBuilder Runtime.exec PowerShell,

Get-ItemProperty HKLM: \ Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall * | Select-Object DisplayName | where {$ _. DisplayName -match "perl"}

Replace "perl" with your choice of software and stream output from them and process it.

If PERL (for the above question), follow below 2 steps to set the path and run the perl script from java

Step 2 - if available, install it in the environment path using java code.

Step 3 - Run your perl script.

0
source

Source: https://habr.com/ru/post/1718086/


All Articles