xref: /AOO41X/main/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir import java.util.*;
2*cdf0e10cSrcweir import java.awt.*;
3*cdf0e10cSrcweir 
4*cdf0e10cSrcweir /** This class prints out the system properties.
5*cdf0e10cSrcweir 
6*cdf0e10cSrcweir     We cannot print the strings directly because of encoding issues. Since
7*cdf0e10cSrcweir     about 1.3.1 one can start java with the option -Dfile.encoding=UTF-8, but
8*cdf0e10cSrcweir     unfortunately this works only with later update - versions (for example,
9*cdf0e10cSrcweir     1.3.1_07). Therefore we use this scheme. The property string has this form:
10*cdf0e10cSrcweir     name=value
11*cdf0e10cSrcweir 
12*cdf0e10cSrcweir     Every character is cast to an integer which value is printed, followed by a
13*cdf0e10cSrcweir     space. If all characters of the string are printed, then a new line is printed.
14*cdf0e10cSrcweir */
15*cdf0e10cSrcweir public class JREProperties
16*cdf0e10cSrcweir {
17*cdf0e10cSrcweir     static public void main(String[] args)
18*cdf0e10cSrcweir     {
19*cdf0e10cSrcweir          try
20*cdf0e10cSrcweir         {
21*cdf0e10cSrcweir             boolean bNoAccess = false;
22*cdf0e10cSrcweir             if(args.length > 0)
23*cdf0e10cSrcweir             {
24*cdf0e10cSrcweir                 if (args[0].equals("noaccessibility"))
25*cdf0e10cSrcweir                     bNoAccess = true;
26*cdf0e10cSrcweir             }
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir             //Find out on what operation system we are running. On Windows 98
29*cdf0e10cSrcweir             //we must not call getDefaultToolkit, because the office may freeze
30*cdf0e10cSrcweir             //#i44608.
31*cdf0e10cSrcweir             boolean bW98 = false;
32*cdf0e10cSrcweir             String os = System.getProperty("os.name");
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir             if (os != null)
35*cdf0e10cSrcweir             {
36*cdf0e10cSrcweir                 os = os.trim();
37*cdf0e10cSrcweir                 if (os.equalsIgnoreCase("Windows 98") ||
38*cdf0e10cSrcweir                     os.indexOf("Windows 98") != -1)
39*cdf0e10cSrcweir                     bW98 = true;
40*cdf0e10cSrcweir             }
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir             //We need to be able to switch this part off because
43*cdf0e10cSrcweir             //it causes an exception if the DISPLAY variable has
44*cdf0e10cSrcweir             //a false value. Setting the noaccessibility argument
45*cdf0e10cSrcweir             //can be done by providing a sunjavaplugin.ini with
46*cdf0e10cSrcweir             //the bootstrap parameter JFW_PLUGIN_NO_NOT_CHECK_ACCESSIBILITY
47*cdf0e10cSrcweir             //set to "1"
48*cdf0e10cSrcweir             if (bNoAccess == false && ! bW98)
49*cdf0e10cSrcweir             {
50*cdf0e10cSrcweir                 try{
51*cdf0e10cSrcweir                     //This line is needed to get the accessibility properties
52*cdf0e10cSrcweir                     Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
53*cdf0e10cSrcweir                 }
54*cdf0e10cSrcweir                 catch(Throwable e)
55*cdf0e10cSrcweir                 {
56*cdf0e10cSrcweir                     System.err.println(e);
57*cdf0e10cSrcweir                 }
58*cdf0e10cSrcweir             }
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir             Properties p = System.getProperties();
62*cdf0e10cSrcweir             Enumeration e = p.propertyNames();
63*cdf0e10cSrcweir             for (; e.hasMoreElements() ;) {
64*cdf0e10cSrcweir                 String sProp = (String) e.nextElement();
65*cdf0e10cSrcweir                 String sCompleteProp = sProp + "=" + p.getProperty(sProp);
66*cdf0e10cSrcweir                 char[] arChars = new char[sCompleteProp.length()];
67*cdf0e10cSrcweir                 sCompleteProp.getChars(0, sCompleteProp.length(), arChars, 0);
68*cdf0e10cSrcweir                 for (int c = 0; c < arChars.length; c++) {
69*cdf0e10cSrcweir                     System.out.print(String.valueOf((int) arChars[c]));
70*cdf0e10cSrcweir                     System.out.print(" ");
71*cdf0e10cSrcweir                 }
72*cdf0e10cSrcweir                 System.out.print("\n");
73*cdf0e10cSrcweir             }
74*cdf0e10cSrcweir         }
75*cdf0e10cSrcweir         catch(Exception e)
76*cdf0e10cSrcweir         {
77*cdf0e10cSrcweir             System.err.println(e);
78*cdf0e10cSrcweir         }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir         System.exit(0);
81*cdf0e10cSrcweir     }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir }
86