views:

111

answers:

1

I have a vendor Applet that is trying to use no longer supported locale settings.

De compiled Code is as follows

 String s1 = System.getProperty("java.version");
 String s2 = System.getProperty("user.language");
 String s;
    if(s1.regionMatches(true, 0, "1.4", 0, 3))
        s = System.getProperty("user.country");
    else
        s = System.getProperty("user.region");
    m_Locale = new Locale(s2, s);

The problem is other applications on the client machine require JRE 1.5 and higher.

So the line if(s1.regionMatches(true, 0, "1.4", 0, 3)) is always kicking into the else

 s = System.getProperty("user.region"); always returns null in JRE 1.4 or higher.

So new Locale(s2, s);

is being called with a null parameter throwing a nullpointer.

I know this code was put in so long ago to support older JRE's namely 1.1 and 1.3 in which user.region was a valid system property.

The way I see it I have 2 options.

  1. Engage the vendor and hope they will make corrections without telling us to spend money on an upgrade.

  2. Recompile the code with corrections made and re sign the jars with my own certificate. And possibly break a licensing/support agreement.

Or is their a third option? I haven't seen any way to set a system property in java without doing so in the code itself. Is there a way? I have full access to client machines if need be to push a file to them. I just don't know how to add or change a default java system property without using a cmd line arg or doing so in the code.

+1  A: 

Seeing as how applets are launched via Java plug-in and you have access to client machines, you may want to try setting user.region as runtime parameter in your Java Plug-In Control Panel. See details here

ChssPly76
This works great thanks so much.
Knife-Action-Jesus