System.getproperty ()- Gets System parameters. The main purpose of this article is to work with this method. Just to summarize

Because all classes in java.io interpret relative pathnames as starting from the user’s current working directory, you should be aware of the current directory.

This can be done by calling System.getProperty(“user.dir”); To obtain.

/ * * * Java version Java runtime environment version of Java. The vendor Java. Java runtime environment suppliers vendor. The url url Java. Java suppliers vm. Specification. Version Java virtual machine specification version of Java. Vm. Specification. The vendor Java. Java virtual machine specification supplier vm. Specification. The name is the name of the Java virtual machine specification. Java vm. Java version Java virtual machine implementation version. Vm. Vendor supplier implement Java Java virtual machine. The vm. The name name of the Java virtual machine implementation Java. The specification. The specification version version of Java runtime environment Java. Specification. Vendor Java runtime environment standard Java. The supplier specification. Name the Java runtime environment specification name OS. The name is the name of the operating system OS. The arch of the operating system architecture Separator File separator ("/" on UNIX.) path.separator Path separator (" : "on UNIX. Separator Line separator (/ N on UNIX) Java.home Java installation directory java.class.version Java class format Version java.class.path Java class path Java.library. path List of paths searched when the library is loaded java.io. Tmpdir Default temporary file path java.com Name of the JIT compiler to be used by piler Java.ext. dirs Path to one or more extended directories User. name User account name user.home Home directory user.dir */
Copy the code
public class Test {
 
        public static void main(String[] args) throws MalformedURLException, URISyntaxException {
 
                System.out.println("java.home : "+System.getProperty("java.home"));
 
                System.out.println("java.class.version : "+System.getProperty("java.class.version"));
 
                System.out.println("java.class.path : "+System.getProperty("java.class.path"));
 
                System.out.println("java.library.path : "+System.getProperty("java.library.path"));
 
                System.out.println("java.io.tmpdir : "+System.getProperty("java.io.tmpdir"));
 
                System.out.println("java.compiler : "+System.getProperty("java.compiler"));
 
                System.out.println("java.ext.dirs : "+System.getProperty("java.ext.dirs"));
 
                System.out.println("user.name : "+System.getProperty("user.name"));
 
                System.out.println("user.home : "+System.getProperty("user.home"));
 
                System.out.println("user.dir : "+System.getProperty("user.dir"));
 
                System.out.println("package: "+Test.class.getPackage().getName());
 
                System.out.println("package: "+Test.class.getPackage().toString());
  
                String packName = Test.class.getPackage().getName();
 
                /*URL packurl = new URL(packName);
                System.out.println(packurl.getPath());*/
 
                URI packuri = new URI(packName);
 
                System.out.println(packuri.getPath());
 
                //System.out.println(packuri.toURL().getPath());
 
                System.out.println(packName.replaceAll("//.", "/"));
 
                System.out.println(System.getProperty("user.dir")+"/"+  (Test.class.getPackage().getName()).replaceAll("//.", "/")+"/");
 
        }
 
} 
Copy the code

As a programmer, the ability to quickly set up environments and quickly test locally is essential.

Thank you for reading this, if this article is well written and if you feel there is something to it

Ask for a thumbs up 👍 ask for attention ❤️ ask for share 👥 for 8 abs I really very useful!!

If there are any mistakes in this blog, please comment, thank you very much! ❤ ️ ❤ ️ ❤ ️ ❤ ️