Home > Java > Javagetting Started > body text

How to write the Java path in Linux?

angryTom
Release: 2020-02-03 13:17:35
Original
3383 people have browsed it

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");
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!