JDK-supported character sets and system attribute values

Source: Internet
Author: User

System attribute values and character sets are often used in Java development. Frequent queries are really unpleasant. you have to write a code to check it out. Paste it out and it will be easy to use later.

Obtain the character set supported by the current JDK

Public static void getJDKEncoding () {SortedMap <String, Charset> map = Charset. availableCharsets (); for (String alias: map. keySet () {System. out. println ("alias:" + alias + "\ t Character Set object:" + map. get (alias ));}}
Alias: alias
Character Set object: Charset
Big5 Big5
GBK GBK
UTF-8 UTF-8
ISO-8859-1
......
ISO-8859-1
.....

A total of 167 types are supported.

Obtains information about the current system.

/*** Get the current System environment information */public static void getSystemProperties () {Properties p = System. getProperties (); for (Object key: p. keySet () {System. out. println ("name:" + key + "\ tvalue:" + p. get (key ));}}
Key: attribute name Value: Attribute Value Description
Java. runtime. name Java (TM) SE Runtime Environment
Sun. boot. library. path C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ bin
Java. vm. version 23.25-b01 Java Virtual Machine version
Java. vendor. url Http://java.oracle.com/ Provider URL
Path. separator ; The system path delimiter for Linux is ":", which has been planted.
Java. vm. name Java HotSpot (TM) Client VM Java Virtual Machine name; among other Java virtual machines, Sun Classic/ExactVM, the world's first commercial Java Virtual Machine), IBMJ9, etc.
Sun. jnu. encoding GBK File Name Encoding
Java. runtime. version 1.7.0 _ 25-b17
Java. library. path Values in system environment variables

File. separator \

File directory delimiter in Windows)

Linux /)

File. encoding UTF-8 File Content Encoding
Sun. boot. class. path C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ lib \ resources. jar; C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ lib \ rt. jar; C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ lib \ sunrsasign. jar; C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ lib \ jsse. jar; C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ lib \ jce. jar; C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ lib \ charsets. jar; C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ lib \ jfr. jar; C: \ Program Files \ Java \ jdk1.7.0 _ 25 \ jre \ classes
Sun. java. launcher SUN_STANDARD
Java. vm. specification. name Java Virtual Machine Specification
Java. vm. specification. vendor Oracle Corporation Provider
Java. specification. name Java Platform API Specification Specification
Sun. management. compiler HotSpot Client Compiler
Java. class. version 51.0 Important: major. minor; Class file version number
Line. separator \ R

Windows (\ r)

Liunx (\ n)

The above code is hard to display. You can view the result through debugging: 650) this. length = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/112H02c0-0.png "title =" qqpinyin unnamed .png "data-pinit =" registered "width =" 200 "height =" 60 "border =" 0 "hspace =" 0 "vspace = ""0" style = "width: 200px; height: 60px; "/>

Java. io. tmpdir C: \ Users \ ZHANGX ~ 1 \ AppData \ Local \ Temp \

Temporary directory

You can set:

java -Djava.io.tmpdir=/path/to/tmpdir


Java. awt. printerjob Sun. awt. windows. WPrinterJob
Sun. arch. data. model 32 JDK and JRE have nothing to do with the number of bits)
Sun. cpu. endian Little Small-end Mode
Sun. desktop Windows

The following is a user-level information:


Key: attribute name Value: Attribute Value Description
User. country CN Country
User. dir E: \ workspace _ jsmart \ Andvance Working directory
OS. arch X86 System attributes of JRE are independent of the number of digits of the operating system)
OS. name Windows 7 Operating System
OS. version 6.1 Operating system version
User. home C: \ Users \ Zhang User directory
User. timezone
User's Time Zone
User. name Zhang Username of the current logon System
User. language Zh Language, corresponding to country information, which can be found in the language of the browser Internet option)

The value of "OS. arch" has nothing to do with the number of digits of the operating system. It depends on the number of JRE digits installed on the machine. See:

Bytes.

See an article:

Java's "OS. arch" System Property is the Bitness of the JRE, NOT the Operating System

Bytes.

import com.sun.servicetag.SystemEnvironment;public class OSArchLies {                                            public static void main(String[] args) {                                                // Will say "x86" even on a 64-bit machine    // using a 32-bit Java runtime    SystemEnvironment env =        SystemEnvironment.getSystemEnvironment();    final String envArch = env.getOsArchitecture();                                                // The os.arch property will also say "x86" on a    // 64-bit machine using a 32-bit runtime    final String propArch = System.getProperty("os.arch");                                                System.out.println( "getOsArchitecture() says => " + envArch );    System.out.println( "getProperty() says => " + propArch );                                              }}

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/112H01M6-1.gif "/> some of the above property values are very confusing, mostly because of the lack of in-depth research on JVM and JRE, and their respective development process, in addition, the name of the attribute name is disturbing.

I hope all of you will specify the above questions for my experiment and correction.

This article is from the "wild horse red dust" blog and will not be reposted!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.