- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Java Home Directory
Use the System.getProperty() method in Java to get the Java Home Directory.
It’s syntax is −
String getProperty(String key)
Above, the key is the name of the system property. Since, we want the Java Home Directory name, therefore we will add the key as −
java.home
The following is an example −
Example
public class Demo { public static void main(String[] args) { System.out.println("Get Java Home Directory = " + System.getProperty("java.home")); System.out.print("Java Specification Version: "); System.out.println(System.getProperty("java.specification.version")); System.out.print("java Runtime Environment (JRE) version: "); System.out.println(System.getProperty("java.version")); } }
Output
Get Java Home Directory = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.fc26.x86_64/jre Java Specification Version: 1.8 java Runtime Environment (JRE) version: 1.8.0_141
- Related Articles
- How to get the home directory in Python?
- Java Program to Get Current Working Directory
- Get the Current Working Directory in Java
- Get Operating System temporary directory / folder in Java
- Java Program to get name of parent directory
- Java Program to get the content of a directory
- Java Program to get the name of the parent directory of the file or directory
- How to find the real user home directory using Python?
- Java Program to get name of specified file or directory
- Golang Program to print the home directory of the current user
- Get the absolute path for the directory or file in Java
- How to Change the Default Home Directory of a User on Linux?
- How to get the list of jpg files in a directory in Java?
- Golang program to get current working directory
- How to get the names of the empty directories in a directory in Java?

Advertisements