Home  >  Article  >  Java  >  How to write the Java path in Linux?

How to write the Java path in Linux?

angryTom
angryTomOriginal
2020-02-03 13:17:353436browse

How to write the Java path in Linux?

#How to write the java path in Linux?

In Unix/Linux, paths are separated by forward slash "/", such as "cd /home/java".

In java code development \ represents the escape character .

Relative path and absolute path

. Refers to the current directory

.. Refers to the upper-level directory of the current directory

./book represents the book folder under the current directory

/book represents the book folder under the current drive letter

Linux absolute path: the path starting with the root root directory / is as follows / represents the root root directory

Below are some operations for using Java to obtain the path in Linux:

// 分隔符
String fileSeperator = File.separator;

// 用户主目录
String userHome = System.getproperties().getProperty("user.home");

// Java实时运行环境的安装目录
String javaPath = System.getproperties().getProperty("java.home");

// 操作系统名称
String osName = System.getproperties().getProperty("os.name");

// 当前用户程序所在目录
String userDir = System.getproperties().getProperty("user.dir");

// JDK的安装目录
String jdkDir = System.getproperties().getProperty("java.ext.dirs");

Recommended related articles and tutorials: Getting started with java Tutorial

The above is the detailed content of How to write the Java path in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is java algorithmNext article:what is java algorithm