erpi
Posts: 5
Joined: Mon Sep 19, 2005 5:19 am

adding files to current JRE

Hi,

I have a simple java app to install, but can not find out how to do it using AI 3.2 for java.
My app uses the Java comm api, requiring files to be placed in specific directories of the active JRE. Most of my users have multiple JRE's installed, which must not be upset and I do NOT want to bundle another JRE. Offering a download if no compatible version exists would be OK.

1- How do I find the current JRE path?

In another another post this solution was offered:
"You could use a search for a registry key. The JavaHome registry entry stores the value to the Java directory. It's location is HKLM/Software/JavaSoft/Java Runtime Environment/x.x.x. (xxx = the version). Then you could use the property resulted after the search"

Unfortunately, it does not work that way. HKLM/Software/JavaSoft/Java Runtime Environment/currentversion gives the main version (like 1.5)
then using that you have to get HKLM/Software/JavaSoft/Java Runtime Environment/1.5/JavaHome which returns what we need (C:\Program Files\Java\jre1.5.0_04)

Please explain how to perform this double lookup, and then make a propertybased directory with the result ?

2- Assuming we just pick one that "might" exist, the way you suggest and make it into a property base directory. We can now put files in that directory. But what if the search fails and the key is not there? How do I handle that case?

3- I have not found any Java specific features in AI3.2 that help me with this installation. I see no benefit to them. Solving the problems above was exactly what I hoped for. Am I taking the wrong approach?

Please help, thanks,

Erwin
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

The files of your application should be placed in your installation folder, not in the folders of the JVM.

In order for your application to find them, you should add the JAR files in the classpath and the folder containing the DLL (if any) in the library path. Copying the files in the folders of the JRE is not the best approach.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
erpi
Posts: 5
Joined: Mon Sep 19, 2005 5:19 am

Mihai,

>The files of your application should be placed in your installation folder, >not in the folders of the JVM.

I appreciate your comment, please direct it to SUN, because its is the SUN comm API that REQUIRES these files to be in the places I have indicated. Nothing I can do about it, and it will not work otherwise.
All my application files are placed, as you rightly say, in the application folder.

Given this fact of life, is there anything you can do to help me? It will be appreciated.

Regards, Erwin
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

If you want to install the file in the folders of the JRE the easiest
way would be to use a bundled JRE.

An alternative solution requires you to know the main JRE on the target
machine at install time. As you say, this obviously cannot be done.
There is also the problem of what happens when Java is updated (a newer
version will be used).

To solve these two things you should:

- find out what is the main JRE at the time of install, and install the
files at it's install location.
- be sure your application preferred version will be that one.

So, in order to do this you need a custom action. This custom action
does a registry enumeration search and finds the main JRE. The key name
gives the version number and it's value is the path. The two are
returned into two properties.

You then enter the name of the version property in the Preferred Java
Version list.

The path property can be used to make a property based folder and
install the files there.

Hope this helps.

If you have further questions I'll be glad to help you.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
erpi
Posts: 5
Joined: Mon Sep 19, 2005 5:19 am

Ini file setting

Mihai,

I have left the JRE for what it is. No idea how to approach the custom action. It seems more work than I have time for...

I am now trying to install the programs configuration file. It is an ini file with the same name as the application and it comes preconfigured.
However some ini settings need to be updated with the installation directory ([targetdir]), after the ini file has been installed.
I can not find out how to do this. If I try to import my ini file I get an exception. If I add it to the installation there seems to be no way to edit the existing sections or keys. What is the (correct) way to do this?

Erwin
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

Every Java product comes with an INI files to store the settings for the launcher. If your Java Product name is, say, "Prod", two files will be added to your project, Prod.exe and Prod.ini. The Prod.ini file is read-only and cannot be modified. If you need to store some settings in an INI file it must have another name.

About the exception you are getting. Is that an error message or a program crash? We are always very careful to investigate such issues.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
erpi
Posts: 5
Joined: Mon Sep 19, 2005 5:19 am

Mihai,

>About the exception you are getting. Is that an error message or a >program crash? We are always very careful to investigate such issues.

I have investigated the Exception further. The ini file import function gets confused because of my ini file contents. I have one ini section that contains Java regular expressions. The syntax conflicts with the identifiers AI uses for its variables, and it does not accept my ini section and fails.
The problematic section is:

[patterns]
PATTERN_HEADER =[=]{20,}.*
PATTERN_SEPARATOR =[-]{20,}.*
PATTERN_FOOTER =[=]{20,}.*
PATTERN_PROCESS_ERROR =(Err\s\.)+?

If you can come up with a workaround for this, even if it means defining a 1:1 substitution variable, or perhaps update AI to handle this better, I will be grateful.

Best regards,

Erwin
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

You are right, this is a bug. AI get confused by the [] parentheses in the syntax of the regular expressions. This will be fixed in a future release.

For know, here is a workaround. If you don't need any formatted values in that INI file you can import it as a regular file. This way, AI doesn't analyze it's content.

If the file needs to have formatted values I would suggest splitting this INI file into two files. One will contain the plain values (including the regular expressions). This can be imported as a regular file. The second INI file will contain the formatted values. Of course, this also means a small code change in your application.

Hope this helps.

All the best,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
erpi
Posts: 5
Joined: Mon Sep 19, 2005 5:19 am

ini file and java service problems

Mihai,

The ini workarounds you suggested do not work for our application. Importing the ini file causes the users ini settings to be overwritten with every update, which is unacceptable behaviour. And using 2 ini files is an unacceptable design.

My next problems is, I tried starting the application as a service, which was a reason to select the AI product. Console app works OK, but then changing the settings to Win32 Service causes the application not to work at all. No errors get logged, no service gets started. I have no idea where to look. Can you help?

I would really appreciate some support on these problems. Could you please fix the problem with the ini file (who would ever need AI formatted variables in their applications ini settings anyway?) and please provide more info on running as a service?

I seem to run into brick walls with your product, especially with the Java support, which after paying $299 for a product I can not use, makes me feel bad.

Thank you,

Erwin
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi Erwin,

AI is designed so that any value that contains [] is interpreted as a property. This is required if the user needs some values in it's INI file that are available during install, for example TARGETDIR.

Unfortunately, this is conflicting with the way the regular expressions are formatted. The fix would be for AI to recognize a regular expression and not to treat it as property.

Until then, here is a workaround that will meet your requirements. To avoid the problem of the regular expressions, create a new property that will store the regular expression string. Use this property as the value of the INI entry.

Example:
- In the "Install Parameters" tab have a property called, say, String1, with the value [=]{20,}.*
- In the INI file have the entry PATTERN_HEADER with the value [String1].

Regarding the Java Service, AI's help comes with a working example of a Java Service. Also, there are tutorials that may provide a useful guidance on creating a Java Service. These can also be found at:

http://www.advancedinstaller.com/user-g ... rvice.html

Also, a good idea would be to have enable the "Reduced usage of operating-system signals" option, in the "Edit JVM Parameters" dialog. This way you can avoid an unwanted shut-down of the application.

If you experience further problems you could send the AIP file at support at advancedinstaller dot com and we can see if there is any problem.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
Phil
Posts: 22
Joined: Sat Aug 27, 2005 3:47 am

Mike wrote: .....
So, in order to do this you need a custom action. This custom action
does a registry enumeration search and finds the main JRE. The key name
gives the version number and it's value is the path. The two are
returned into two properties.

You then enter the name of the version property in the Preferred Java
Version list.

The path property can be used to make a property based folder and
install the files there.

If you have further questions I'll be glad to help you.

Regards,
Mihai
Hi, We had this same problem a long time ago but we've worked around it. I want to fix this once and for all...
If we search:
HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion
and get "1.6" (eg we end up with variable 'JavaCurrentVersion=1.6'), how do we use variable JavaCurrentVersion in a custom action to do the second registry lookup?
(I.e effectively search "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\${JavaCurrentVersion}\JavaHome".)
When I go to the 'New Custom Action Wizard', there is not an option to search the registry...

Thanks in advance,
Phil
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi Phil,
how do we use variable JavaCurrentVersion in a custom action to do the second registry lookup? When I go to the 'New Custom Action Wizard', there is not an option to search the registry...
The registry search can be performed by the custom action by using custom code. For example, you can use a VBScript custom action which looks like this:

Code: Select all

const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
 strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\JavaSoft\Java Runtime Environment\"
strValueName = "CurrentVersion"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

Session.Property("REG_VALUE")=strValue
MsgBox Session.Property("REG_VALUE")
The property REG_VALUE contains the searched registry value. You can read more about custom actions here:
http://www.advancedinstaller.com/user-g ... -page.html

Although I'm not sure if it exists, you can modify this script to search for the "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\${JavaCurrentVersion}\JavaHome" registry entry.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Phil
Posts: 22
Joined: Sat Aug 27, 2005 3:47 am

Thanks for the vbs... but it doesn't work (error, "Object required: 'Session'" on line 12). I don't know anything about vbs and how to fix it - can you point me in the direction of a good vbs tutorial or resource? Otherwise this isn't really a solution :(

Long-term it would be very useful if AI could do a registry search where the key can take user properties (just like custom actions can access user defined properties), for example:
key: SOFTWARE\JavaSoft\Java Runtime Environment\[JavaCurrentVersion]

(where JavaCurrentVersion is the result of the first registry search).

Thanks
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

Please make sure that you have written this code in a .vbs file (for example "my_ca.vbs"). This file must be added as an Attached Custom Action in the "Custom Actions" page. Also, in order to have access to installer properties, you must set this custom action as Immediate in the "Custom Action Properties" page:
http://www.advancedinstaller.com/user-g ... types.html

Note that this is a tested custom action and it works as expected.
Long-term it would be very useful if AI could do a registry search where the key can take user properties (just like custom actions can access user defined properties), for example:
key: SOFTWARE\JavaSoft\Java Runtime Environment\[JavaCurrentVersion]
If you are referring to writing a property in the registry then please note that this can be done by using the "Registry" page. For this, you recreate the registry structure you need (for example: "HKLM\Software\JavaSoft\Java Runtime Environment") and use your custom property to create the registry value.

If this is not what you need then please give me more details about this.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Phil
Posts: 22
Joined: Sat Aug 27, 2005 3:47 am

Hi, sorry only just got back to this.

Ok, I could not see how your custom action could do the right thing so I added:

Code: Select all

strKeyPath2 = "SOFTWARE\JavaSoft\Java Runtime Environment\" & strValue & "\"
strValueName2 = "JavaHome"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,strValueName2,strValue2
Session.Property("REG_VALUE")=strValue2
Then the custom action pops up a message box and reports the path C:\Program Files (x86)\Java\jre1.6.0_03
... great.

However what should I do next? Should there be a session variable in the AI project called 'REG_VALUE'? Because after I ok the message box, the installer reports:
There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor."
This happens even when I run your "tested custom action" as above... :(
What is going wrong?

Thanks, Phil

Return to “Common Problems”