Here you can find the source of makeCurrentDirectoryThatOfExecutable(String executable)
Parameter | Description |
---|---|
executable | fullpath executable, as in "c:\some\dir\file.exe" and not just "file.exe" |
public static String makeCurrentDirectoryThatOfExecutable(String executable)
//package com.java2s; /** This class is a PanelLeft factory, creating all panels based on the * contents of the panels.xml file./* ww w .j av a 2s.c o m*/ * * Last Updated: May 25, 2011 * * by Rick C. Hodgin * Cossatot Analytics Laboratories, LLC. (Cana Labs) * * (c) Copyright Cana Labs. * Free software licensed under the GNU GPL2. * * @author Rick C. Hodgin * @version 1.0.0 * * Change history: * 2011-05-25 - 1.0.0 - Initial release * */ import java.io.File; public class Main { /** * Set the directory to that of the executable, such that "c:\some\dir\file.exe" * will set to "c:\some\dir\" * @param executable fullpath executable, as in "c:\some\dir\file.exe" and * not just "file.exe" * @return previous directory */ public static String makeCurrentDirectoryThatOfExecutable(String executable) { String curDir, newDir; curDir = getCurrentDirectory(); newDir = new File(executable).getParent(); setCurrentDirectory(newDir); return (curDir); } public static String getCurrentDirectory() { return (System.getProperty("user.dir")); } public static void setCurrentDirectory(String dir) { System.setProperty("user.dir", dir); } }