1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 import java.util.*;
25 import java.awt.*;
26 
27 /** This class prints out the system properties.
28 
29 	We cannot print the strings directly because of encoding issues. Since
30 	about 1.3.1 one can start java with the option -Dfile.encoding=UTF-8, but
31 	unfortunately this works only with later update - versions (for example,
32 	1.3.1_07). Therefore we use this scheme. The property string has this form:
33 	name=value
34 
35 	Every character is cast to an integer which value is printed, followed by a
36 	space. If all characters of the string are printed, then a new line is printed.
37 */
38 public class JREProperties
39 {
main(String[] args)40 	static public void main(String[] args)
41 	{
42 		 try
43 		{
44 			boolean bNoAccess = false;
45 			if(args.length > 0)
46 			{
47 				if (args[0].equals("noaccessibility"))
48 					bNoAccess = true;
49 			}
50 
51 			//Find out on what operating system we are running. On Windows 98
52 			//we must not call getDefaultToolkit, because the office may freeze
53 			//#i44608.
54 			boolean bW98 = false;
55 			String os = System.getProperty("os.name");
56 
57 			if (os != null)
58 			{
59 				os = os.trim();
60 				if (os.equalsIgnoreCase("Windows 98") ||
61 					os.indexOf("Windows 98") != -1)
62 					bW98 = true;
63 			}
64 
65 			//We need to be able to switch this part off because
66 			//it causes an exception if the DISPLAY variable has
67 			//a false value. Setting the noaccessibility argument
68 			//can be done by providing a sunjavaplugin.ini with
69 			//the bootstrap parameter JFW_PLUGIN_NO_NOT_CHECK_ACCESSIBILITY
70 			//set to "1"
71 			if (bNoAccess == false && ! bW98)
72 			{
73 				try{
74 					//This line is needed to get the accessibility properties
75 					Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
76 				}
77 				catch(Throwable e)
78 				{
79 					System.err.println(e);
80 				}
81 			}
82 
83 
84 			Properties p = System.getProperties();
85 			Enumeration e = p.propertyNames();
86 			for (; e.hasMoreElements() ;) {
87 				String sProp = (String) e.nextElement();
88 				String sCompleteProp = sProp + "=" + p.getProperty(sProp);
89 				char[] arChars = new char[sCompleteProp.length()];
90 				sCompleteProp.getChars(0, sCompleteProp.length(), arChars, 0);
91 				for (int c = 0; c < arChars.length; c++) {
92 					System.out.print(String.valueOf((int) arChars[c]));
93 					System.out.print(" ");
94 				}
95 				System.out.print("\n");
96 			}
97 		}
98 		catch(Exception e)
99 		{
100 			System.err.println(e);
101 		}
102 
103 		System.exit(0);
104 	}
105 
106 }
107