This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Getting Java Version
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 29, 2010
10:34 AM
Getting Java Version
This isn't exactly related to InstallShield per se, but I was wondering if anyone else has found a solution to this in InstallShield.
I need to get the version of Java I am installing with my product. I'm only extracting Java to my product but not actually installing it on the system, so it won't have any values in the registry.
To get the version I use "pathtojava\java.exe -version > example.txt" on the command line. The problem is, the file is created but nothing is written to it, even though the command dialog will display the version info. I need it written to a file because I am assuming that reading the file is the only way to get results from a command line execution.
Does anyone have any idea on how to make this work? Or another way for InstallShield to get the version of Java?
I need to get the version of Java I am installing with my product. I'm only extracting Java to my product but not actually installing it on the system, so it won't have any values in the registry.
To get the version I use "pathtojava\java.exe -version > example.txt" on the command line. The problem is, the file is created but nothing is written to it, even though the command dialog will display the version info. I need it written to a file because I am assuming that reading the file is the only way to get results from a command line execution.
Does anyone have any idea on how to make this work? Or another way for InstallShield to get the version of Java?
(8) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 29, 2010
12:00 PM
You could try java.exe -version 2> example.txt
This should redirect stderr I believe, and it worked for me with getting the version output from java.exe.
This should redirect stderr I believe, and it worked for me with getting the version output from java.exe.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 29, 2010
12:29 PM
that did it. thanks!
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 29, 2010
06:07 PM
(As an alternative, would detecting the version of java.exe do it?)
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 30, 2010
08:59 AM
I did consider checking the version of Java.exe file. It has two different version properties, and the format is a bit different than what you typically see in JDK releases (1.6.0_20). Since I need to be logging this info as well, it was easier and better to get the more typical format of the Java version.
However, now I'm having a problem with the method suggested before. When I execute "pathtojava\java.exe -version 2> c:\sample.txt" from the command line, it works fine. But for some reason when using LaunchAppAndWait the file does not get created. LaunchAppAndWait returns 0, and I have a MessageBox displaying the exact command that is executed, and when I copy and execute it myself it works just fine. I even see the command prompt appear and the command executes normally from LaunchAppAndWait, but no file is created. I have no idea what's going wrong here, any ideas?
However, now I'm having a problem with the method suggested before. When I execute "pathtojava\java.exe -version 2> c:\sample.txt" from the command line, it works fine. But for some reason when using LaunchAppAndWait the file does not get created. LaunchAppAndWait returns 0, and I have a MessageBox displaying the exact command that is executed, and when I copy and execute it myself it works just fine. I even see the command prompt appear and the command executes normally from LaunchAppAndWait, but no file is created. I have no idea what's going wrong here, any ideas?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 30, 2010
05:00 PM
It might depend on the particular command; if the 2> redirect operator doesn't work directly as a command-line argument, perhaps try creating a batch file and launching that?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 01, 2010
10:10 AM
Using the batch file worked. I still don't understand why InstallShield can't execute this directly. I would still prefer to have it all done within the InstallScript function rather than create a dependency on a batch file that has to be included in the MSI file, but this works for now. Thanks.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 01, 2010
10:18 AM
I think the issue is that redirect operators aren't handled by the CreateProcess or ShellExecute API functions that LaunchApplication uses, but instead gets handled by the command processor.
As a test, a custom action that launches
As a test, a custom action that launches
cmd.exe /c set > C:\vars.txtseems to work, redirecting a list of environment variables to a file C:\vars.txt without needing a separate batch file...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 01, 2010
12:38 PM
That worked as well, and is a better solution than creating a batch file on fly, thanks. Well from now on I'll know to us cmd.exe instead of calling my app in LaunchAppAndWait if I'm using redirects. I was puzzled for a while as to why they weren't working.