Java examples for java.lang:System
Returns the path and name of the java launcher in which this program is executed.
/******************************************************************************* * Copyright (c) 2014 Karlsruhe Institute of Technology, Germany * Technical University Darmstadt, Germany * Chalmers University of Technology, Sweden * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w w w . j a va 2s. co m*/ * Technical University Darmstadt - initial API and implementation and/or initial documentation *******************************************************************************/ //package com.java2s; import java.io.File; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getJavaLauncher()); } /** * Returns the path and name of the java launcher in which this program is executed. * @return The path and name of the java launcher in which this program is executed. */ public static String getJavaLauncher() { final String launcher = "java"; String java = System.getProperty("sun.boot.library.path"); if (java != null && !java.isEmpty()) { File folder = new File(java); if (folder.isDirectory()) { return new File(folder, launcher).getAbsolutePath(); } else { return launcher; } } else { return launcher; } } }