Basically, I want to put the below logic into an install4j file. It will be used to set the vmoptions in an application. The logic seems to work fine in a test class, but getting it in the correct place and in the correct format within the install4j file has proven rather troublesome for me. I just need to split up the locale into three separate vmoptions:
-Duser.language="en"
-Duser.country="US"
-Duser.variant=""
If country or variant aren't provided, I simply want to put a blank string for it's value.
If any additional information or code is needed to help us work through this scenario, let me know and I will provide it if it is available.
The user selected locale is put into ${installer:sys.languageId}
.
I try to get the string in that variable and it's length by using getVariable(languageId).length()
public class VmOptionsTest {
public static void main(String[] args) {
//languageOne represents ${installer:sys.languageId} in this test case
String languageOne = "en_US";
String language = "";
String country = "";
String variant = "";
//for all the if and else if statements
//this is where I would put getVariable(languageId).length() in install4j file
if (languageOne.length() == 2) {
language = languageOne;
country = "";
variant = "";
JOptionPane.showMessageDialog(null, "-Duser.language=" + language + "\n" +
"-Duser.country=" + country + "\n" + "-Duser.variant=" + variant);
} else if (languageOne.length() == 5) {
language = languageOne.substring(0, 2);
country = languageOne.substring(3, 5);
variant = "";
JOptionPane.showMessageDialog(null, "-Duser.language=" + language + "\n" +
"-Duser.country=" + country + "\n" + "-Duser.variant=" + variant);
} else if (languageOne.length() > 5) {
language = languageOne.substring(0, 2);
country = languageOne.substring(3, 5);
variant = languageOne.substring(6, 8);
JOptionPane.showMessageDialog(null, "-Duser.language=" + language + "\n" +
"-Duser.country=" + country + "\n" + "-Duser.variant=" + variant);
}
}
}
This is the output of the above code.
Well, I finally figured it out.
In my install4j IDE, I created 3 new installer variables.
Then I wrote a script for each one.
Finally, I set the VMoptions
Hope this helps if anyone runs across a similar issue.