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