All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.neo4j.io.proc.ProcessUtil Maven / Gradle / Ivy

There is a newer version: 5.26.1
Show newest version
/*
 * Copyright (c) 2002-2016 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package org.neo4j.io.proc;

import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;

/**
 * Utility methods for accessing information about the current Java process.
 */
public class ProcessUtil
{
    /**
     * Get the path to the {@code java} executable that is running this Java program.
     * 

* This is useful for starting other Java programs using the same exact version of Java. *

* This value is computed from the {@code java.home} system property. * * @return The path to the {@code java} executable that launched this Java process. */ public static Path getJavaExecutable() { String javaHome = System.getProperty( "java.home" ); return Paths.get( javaHome, "bin", "java" ); } /** * Get the list of command line arguments that were passed to the Java runtime, as opposed to the Java program. * * @see RuntimeMXBean#getInputArguments() * @return The list of arguments, as Strings, that were given to the Java runtime. */ public static List getJavaExecutableArguments() { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); return runtimeMxBean.getInputArguments(); } /** * Get the current classpath as a list of file names. * @return The list of file names that makes the classpath. */ public static List getClassPathList() { return Arrays.asList( getClassPath().split( File.pathSeparator ) ); } /** * Get the classpath as a single string of all the classpath file entries, separated by the path separator. * * This is based on the {@code java.class.path} system property. * @see File#pathSeparator * @return The current classpath. */ public static String getClassPath() { return System.getProperty( "java.class.path" ); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy